动态指定要运行的测试用例

命令行参数

$ mvn test -Dtest=com.jianglei.c8_singleton.env1.FactoryTest

也支持通配符

$ mvn test  -Dtest=com.jianglei.c8_singleton.env1.Factory*Test

逗号分隔多个测试类(注意逗号之前不要加空格要不会报错)

$ mvn test -Dtest=com.jianglei.c8_singleton.env1.FactoryTest, com.jianglei.c8_singleton.env1.Factory2Test

通配符与逗号组合使用

$ mvn test -Dtest=com.jianglei.c8_singleton.env1.Factory*Test,com.jianglei.c6_bridge.env1.MachineManageTest

pom.xml中配置包含或排除的测试用例

排除的优先级要比包含的高:如果同时包含和排除了一个相同的测试用例,则此测试用例会被排除

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.20</version>
  <configuration>
    <includes>
      <include>**/*Test.java</include>
    </includes>
    <excludes>
      <exclude>**/*ClassTest.java</exclude>
    </excludes>
  </configuration>
</plugin>

results matching ""

    No results matching ""