How to run individual test in the integration-test target in maven

后端 未结 6 1426
囚心锁ツ
囚心锁ツ 2020-12-23 21:36

We have a hundreds of tests defined for our integration-test phase lifecycle in maven, and they take a long time to finish.

What I want to do is run just one test in

6条回答
  •  清歌不尽
    2020-12-23 22:13

    I struggled through this, and I created an additional profile to use when I wanted to run just one integration test. I hope that I've successfully extracted just the right part here:

        
            integrationTestSingle
            
                
                    
                        maven-surefire-plugin
                        
                            
                                surefire-it
                                integration-test
                                
                                    test
                                
                                
                                    
                                        **/integration/**/${test}.java
                                    
                                    false
                                
                            
                        
                        
                            -Xms256M -Xmx768M -XX:MaxPermSize=256M
                        
                    
    
                    
                        maven-surefire-plugin
                        
                            
                                default-test                                
                                
                                    true
                                
                            
                        
    
                    
                
            
        
    

    Now, I call maven with the integrationTestSingle profile and with -DfailIfNoTests=false -Dtest=NameOfTest, and it doesn't run any of the regular tests during the regular "test" phase, and runs just the NameOfTest test during the integration-test phase.

提交回复
热议问题