【问题标题】:Failsafe plugin: running only the selected tests in command line故障安全插件:仅在命令行中运行选定的测试
【发布时间】:2015-02-24 12:45:51
【问题描述】:

我在 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

但我不能使用故障安全插件来做同样的事情。 真的可行吗?

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

提前致谢!

【问题讨论】:

  • documentation 似乎表明应该可以工作......
  • 它确实适用于这种情况,他们描述了:一个或多个用逗号分隔的类(所有方法),或单个类中的一个/几个方法(并且没有指定其他类)。可能会使用通配符,尽管我没有尝试。但是我的情况不同,如果支持,我找不到任何提及。我的理解是它不会在默认配置下运行。但是它有很多选项可以配置...

标签: junit4 maven-failsafe-plugin


【解决方案1】:

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

不知道如何让它使用逗号分隔值。

【讨论】:

    猜你喜欢
    • 2013-11-12
    • 2016-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多