How to execute JUnit and TestNG tests in same project using maven-surefire-plugin?

前端 未结 12 1984
花落未央
花落未央 2020-12-13 06:04

Right now I have both type of tests but when I say \"mvn test\" it only executes TestNG tests and not Junit. I want to execute both one after another. Any Idea ?

12条回答
  •  抹茶落季
    2020-12-13 06:48

    Based on previous solutions. I found this worked best for us. One more issue we were facing was TestNG trying to run old JUnit tests. We avoided this by naming all TestNG tests differently (e.g. *TestNG.java). Below is the configuration with two executions of surefire-plugin.

        
                org.apache.maven.plugins
                maven-surefire-plugin
                2.12.4
                           
                    none:none   
                    
                        **/*TestNG.java
                     
                
                
                    
                        test-testng
                        test
                        
                            test
                        
                         
                            none:none          
                            org.testng:testng   
                            
                                **/*TestNG.java
                            
                            
                                **/*Test.java
                             
                        
                    
                
            
    

提交回复
热议问题