How to run embedded Tomcat 9 inside Maven 3 for integration testing purposes?

后端 未结 1 1802
情歌与酒
情歌与酒 2021-01-21 20:41

I am trying to run embedded Tomcat 9 inside Maven 3 for integration testing purposes. I was led to cargo-maven2-plugin by other SO answers.

So, attempting t

1条回答
  •  生来不讨喜
    2021-01-21 21:01

    After trying many permutations, this finally worked for me:

            
                org.codehaus.cargo
                cargo-maven2-plugin
                1.7.9
                
                    
                        
                            ${myEnvVar}
                            ... stuff ...
                        
                        tomcat9x
                        
                            https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/9.0.29/tomcat-9.0.29.zip
                        
                    
                    
                        
                            org.codehaus.cargo
                            simple-war
                            war
                            path/to/myapp.war
                            
                                myapp
                            
                        
                    
                    
                        
                            start-server
                            pre-integration-test
                            
                                start
                            
                        
                        
                            stop-server
                            post-integration-test
                            
                                stop
                            
                        
                    
                
            
    

    Use the failsafe plugin to automatically run the Integration Tests between the start and stop:

                
                    maven-failsafe-plugin
                    2.21.0
                    
                        
                            
                                integration-test
                                verify
                            
                            
                            
                        
                    
                
    

    0 讨论(0)
提交回复
热议问题