[英]Maven Surefire Junit test suite
I am using the Maven Surefire plugin in order to run just a specific suite of tests. 我正在使用Maven Surefire插件来运行一组特定的测试。 For instance:
例如:
package suite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import suite.slow.EvenSlowerClassTest;
import suite.slow.SlowClassTest;
@RunWith(Suite.class)
@Suite.SuiteClasses({
SlowClassTest.class,
EvenSlowerClassTest.class
})
public class SlowSuite {
}
By using the maven command 通过使用maven命令
test -DrunSuite=**/FastSuite.class -DfailIfNoTests=false
I can run the FastSuite or SlowSuite test suites explicitly, however, how can I run all test suites that I have or all tests that are not covered in a test suite? 我可以显式运行FastSuite或SlowSuite测试套件,但是,如何运行我拥有的所有测试套件或测试套件中未涵盖的所有测试?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>${runSuite}</include>
</includes>
</configuration>
</plugin>
What i have done in some of our projects, is to use <profiles>
in the pom.xml
to activate special suites of tests. 我在一些项目中所做的是使用
pom.xml
中的<profiles>
来激活特殊的测试套件。 If no profiles are active, all tests will be run with mvn test
(i hope that's what you are looking for) 如果没有激活配置文件,所有测试都将使用
mvn test
运行(我希望这是您正在寻找的)
Like so: 像这样:
<profile>
<id>commit-test</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.3</version>
<configuration>
<groups>com.test.CommitTest</groups>
</configuration>
</plugin>
</plugins>
</build>
Test classes in annotated like so: 测试类注释如下:
@Category(CommitTest.class)
public class SomeTestClass {
}
I don't know if it works with @Suite
and @RunWith
but if your test suites aren't too many classes, it shouldn't be a difficult job to change that. 我不知道它是否适用于
@Suite
和@RunWith
但是如果你的测试套件不是太多的类,那么改变它应该不是一件困难的工作。
command: mvn clean test -Pcommit-test
命令:
mvn clean test -Pcommit-test
我想你可以试试-DrunSuite = ** / * Suite.class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.