How do I include test classes and configuration in my war for integration testing using maven?

前端 未结 7 1410
梦谈多话
梦谈多话 2021-01-12 05:33

I currently have a maven web project that I am attempting to write integration tests for. For the structure of the project, I\'ve defined test stubs under src/test/j

7条回答
  •  花落未央
    2021-01-12 06:03

    You can also do it straightforwardly. This will add both test classes and test resources to the WEB-INF/classes:

            
                maven-antrun-plugin
                1.7
                
                    
                        process-test-classes
                        
                            
                                
                                    
                                
                            
                        
                        
                            run
                        
                    
                
            
    

    I also recommend you place it into separate profile like "integration" and also to override the package name in that profile to not be able to confuse normal war without tests packaged in and the testing war.

    The full example with profile is here. You may run mvn clean package to have a war war-it-test.war without tests included, or you may run mvn clean package -Pintegration to have a war war-it-test-integration.war for the war with tests included.

提交回复
热议问题