Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven Surefire Junit测试套件_Java_Maven_Junit_Surefire - Fatal编程技术网

Java Maven Surefire Junit测试套件

Java Maven Surefire Junit测试套件,java,maven,junit,surefire,Java,Maven,Junit,Surefire,我使用Maven Surefire插件只是为了运行一套特定的测试。 例如: 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({ SlowClass

我使用Maven Surefire插件只是为了运行一套特定的测试。 例如:

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 {

}
通过使用maven命令

test -DrunSuite=**/FastSuite.class -DfailIfNoTests=false
我可以显式地运行FastSuite或SlowSuite测试套件,但是,如何运行我拥有的所有测试套件或测试套件中未包含的所有测试套件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <includes>
            <include>${runSuite}</include>
        </includes>
    </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
${runSuite}

我在我们的一些项目中所做的是在
pom.xml
中使用
来激活特殊的测试套件。如果没有激活的配置文件,则所有测试都将使用
mvn test
运行(我希望这就是您要寻找的)

像这样:

<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>
我不知道它是否适用于
@Suite
@RunWith
,但是如果您的测试套件不是太多的类,那么改变它应该不是一件困难的工作


命令:
mvn clean test-Pcommit test

我想你可以试试-drunsite=***套件。class

mvn test
将在
src/test/java
下运行所有测试(顺便说一句,我没有投反对票)是的,我知道。但是如果我在surefire插件中有include指令(我用pom.xml更新了这个问题),那么默认情况下它会运行一个套件。如果我不添加该include,我将无法运行任何提供参数的套件您是否尝试了
-DrunSuite=***
?@Cédriccoural让属性
runSuite
在maven surefire插件中不存在请参阅文档。它是包含的属性@Cédriccourlet这很有帮助,谢谢。类别注释来自哪里?我可以;在junit框架
junit-4.11
org.junit.experimental.categories
下找不到它,在中不存在类似于
runSuite
的属性。
@Category(CommitTest.class)
public class SomeTestClass {
}