我已经配置了一个仅运行集成测试的配置文件,但它仍在运行所有测试。 这是配置:
<profile> <id>integration</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <executions> <execution> <id>integration-test</id> <goals> <goal>test</goal> </goals> <phase>test</phase> <configuration> <includes> <include>**/*IT.java</include> </includes> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile>我尝试使用正则表达式,如http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html中所解释的那样,但我觉得这不起作用。 我如何只使用IT.java运行测试?
谢谢
I have configured a profile for running only integration tests but it is still running all tests. This is the configuration:
<profile> <id>integration</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <executions> <execution> <id>integration-test</id> <goals> <goal>test</goal> </goals> <phase>test</phase> <configuration> <includes> <include>**/*IT.java</include> </includes> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile>I tried with regex like explained at http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html but I got this not working. How do I get only tests running that end with IT.java?
Thanks
最满意答案
您尚未重新配置surefire运行,而是在生命周期中添加了另一个。 那样,surefire:测试运行两次,一次使用默认执行ID( default-test ),一次使用新执行( integration-test )
如果您只想更改正在运行的测试,可以使用:
<profile> <id>integration</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <includes> <include>**/*IT.java</include> </includes> </configuration> </plugin> </plugins> </build> </profile>这只会重新配置现有的执行。
尽管如此,正如khmarbaise已在评论中写道,仅仅使用maven-failsafe-plugin就更有意义了。 如果你真的想跳过正常的单元测试(为什么你还想要它?),你可以在你的配置文件中明确禁用skipTests (使用skipTests -configuration)。
You have not reconfigured the surefire run, but instead added another one to the lifecycle. That way, surefire:test runs twice, once with default execution id (default-test) and once with your new execution (integration-test)
If you simply want to change the tests being run, you could use:
<profile> <id>integration</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <includes> <include>**/*IT.java</include> </includes> </configuration> </plugin> </plugins> </build> </profile>Which would only reconfigure the existing execution.
Still, as khmarbaise already wrote in a comment, it makes much more sense to simply use the maven-failsafe-plugin. If you really wanted to skip normal unit test (why would you want that, anyway?), you could explicitly disable surefire in your profile (using skipTests-configuration).
更多推荐
发布评论