How to run JUnit tests by category in Maven?

前端 未结 8 1869
说谎
说谎 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条回答
  •  春和景丽
    2020-11-28 22:10

    I had a similar case where I want to run all test EXCEPT a given category (for instance, because I have hundreds of legacy uncategorized tests, and I can't / don't want to modify each of them)

    The maven surefire plugin allows to exclude categories, for instance:

    
        
            NonSlowTests
            
                
                    
                        org.apache.maven.plugins
                        maven-surefire-plugin
                        
                            my.category.SlowTest
                        
                    
                
            
        
    
    

提交回复
热议问题