2015-02-24 85 views
0

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

我要的是通过种皮和case100的命令行方式case0和案例1运行, TestB的case101。 TestA和TestB都有更多我想忽略的方法。 我可以万无一失,插件轻松地做到这一点:

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

,但我不能做使用故障保护,插件一样。 它是否可行?

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

在此先感谢!

+0

[文档](http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#test)似乎暗示应该工作... – 2015-02-24 14:35:18

+0

它真的工作在这些情况下,它们描述了:用逗号(所有方法)分隔的一个或多个类,或者单个类中的一个/几个方法(并且没有指定其他类)。可能会使用通配符,尽管我没有尝试。但是,我的情况是不同的,如果支持,我不能找到任何提及。我的理解是它不会在默认配置下运行。但它有很多选项来配置... – user3155208 2015-02-24 14:55:17

回答

0

请尝试使用“-Dit.test = MyTestClass#myMethod”,因为它通常用于按照记录运行集成测试。请注意,它可以与junit-4.x或TestNG框架一起使用。

不知道如何让它与逗号分隔值虽然工作。

相关问题