故障安全插件:在命令行中仅运行选定的测试

时间:2015-02-24 12:45:52

标签: junit4 maven-failsafe-plugin

我在pom.xml中有以下配置:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
            <includes>
                <include>**/TestA.java</include>
                <include>%regex[.*TestB.*]</include>
            </includes>
        </configuration>
        <executions>
            <execution>
                <id>integration-test</id>
                <goals>
                    <goal>integration-test</goal>
                    <goal>verify</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

我想要的是通过TestA的命令行方法case0和case1以及TestB的case100和case101运行。 TestA和TestB都有更多我想忽略的方法。 我可以使用surefire-plugin轻松完成:

mvn test -Dtest=org.TestA#case0+case1,org.TestB#case100+case101

但我不能使用failsafe-plugin做同样的事情。 它可以吗?

我使用:JUnit 4.11和failsafe / surefire 2.18.1。

提前致谢!

1 个答案:

答案 0 :(得分:0)

请尝试使用“-Dit.test = MyTestClass #myMethod”,因为它通常用于运行集成测试,如文档所示。另请注意,它适用于junit-4.x或TestNG框架。

不知道如何使用逗号分隔值来处理它。

相关问题