How to run JUnit tests by category in Maven?

前端 未结 8 1868
说谎
说谎 2020-11-28 21:59

Using JUnit 4.8 and the new @Category annotations, is there a way to choose a subset of categories to run with Maven\'s Surefire plugin?

For example I h

8条回答
  •  -上瘾入骨i
    2020-11-28 22:34

    You can use

    mvn test -Dgroups="com.myapp.FastTests, com.myapp.SlowTests"
    

    But ensure that you configure properly the maven surefire plugin

    
      org.apache.maven.plugins
      maven-surefire-plugin
      2.11
      
        
          org.apache.maven.surefire
          surefire-junit47
          2.12.2
        
      
    
    

    See docs in: https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html

提交回复
热议问题