【发布时间】:2012-09-05 18:05:30
【问题描述】:
一个关于 Maven - Surefire - Eclipse - JUnit 的新手问题
我已经在我的项目的 pom 文件中配置了 maven-surefire-plugin 来传递一些额外的 JVM 参数,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<argLine>-d64 -Xms128m -Xmx4096m -XX:PermSize=512m -Duser.timezone=UTC -XX:-UseSplitVerifier</argLine>
</configuration>
</plugin>
当我从 Eclipse 作为 Run As->JUnit Test 运行此项目的测试用例时,虽然类路径设置正确,但调用中不包含在 argLine 中指定的其他参数。我必须去手动输入相关Debug Configurations 下的参数。我不太明白 JUnit 如何知道它需要将测试范围的 jar 放在类路径上,并且在某种程度上意味着 Eclipse 中的 JUnit 工具通过 M2E 知道 Maven?如果是这样,我们怎样才能让它也读取 argLine。我知道这听起来很具体 - 但其他人在类似情况下如何管理?
提前致谢!
【问题讨论】:
-
您可以通过在 Eclipse 内 lancher 定义的
Arguments选项卡中输入程序参数来向 Junit 启动配置添加程序参数。 -
请注意,您需要将虚拟机的参数和程序本身的参数分开。
-
我看到 IntelliJ 完全符合我的预期。
标签: eclipse maven junit m2eclipse maven-surefire-plugin