Junit4 and TestNG in one project with Maven

后端 未结 3 989
傲寒
傲寒 2020-12-21 05:38

To run them together there are few options available but I have chosen using different profiles for Junit and TestNG. But now problem is with excluding and including test c

3条回答
  •  一个人的身影
    2020-12-21 06:00

    I didn't find any combined solution online for both Surefire and Failsafe. The POM file changes below worked for me.

    • The Surefire trick is done by explicitly specifying the child plugin for both JUnit and TestNG.
    • The Failsafe trick is done by defining two executions, each with an empty configuration, one for JUnit and the other for TestNG.

    Both solutions are hacks that I found online. I think the link to the Surefire trick is in another answer to this question.

    
    
        maven-surefire-plugin
        ${surefire.version}
        
            
                org.apache.maven.surefire
                surefire-junit47
                ${surefire.version}
            
            
                org.apache.maven.surefire
                surefire-testng
                ${surefire.version}
            
        
    
    
        org.apache.maven.plugins
        maven-failsafe-plugin
        ${failsafe.version}
        
            
                test-testng
                
                    integration-test
                    verify
                
                
                    none:none
                
            
            
                test-junit
                
                    integration-test
                    verify
                
                
                    none:none
                
            
        
               
    
    
    

提交回复
热议问题