Starting external process during integration testing in maven

前端 未结 5 698
礼貌的吻别
礼貌的吻别 2021-01-01 05:24

I want completely automated integration testing for a Maven project. The integration tests require that an external (platform-dependent) program is started before running.

5条回答
  •  孤城傲影
    2021-01-01 06:00

    The cargo maven plugin is a good way to go if you're doing servlet development and want to deploy the resulting WAR for integration testing.

    When I do this myself, I often set up a multi-module project (although that's not strictly nessecarily) and encapsulate all the integration testing into that one module. I then enable the module with profiles (or not) so that it's not blocking the immediate "yeah, I know I broke it" builds.

    Here's the pom from that functional test module - make of it what you will:

    
      
        maven-example
        com.jheck
        1.5.0.4-SNAPSHOT
      
      4.0.0
      com.jheck.example
      functional-test
      Example Functional Test
      pom
    
      
        
          com.jheck.example
          example-war
          war
          provided
          LATEST
        
        
          httpunit
          httpunit
          1.6.1
          test
        
      
    
      
        
    
          
            org.apache.maven.plugins
            maven-compiler-plugin
            
              
                
                  testCompile
                
              
            
          
    
          
            org.apache.maven.plugins
            maven-surefire-plugin
            
              
                integration-test
                
                  test
                
              
            
          
    
          
            org.codehaus.cargo
            cargo-maven2-plugin
            0.3
            
              false 
              
                tomcat5x
                ${project.build.directory}/cargo.log
                
                  
                   
                  http://www.apache.org/dist/tomcat/tomcat-5/v5.5.26/bin/apache-tomcat-5.5.26.zip
    
                  ${installDir}
                
              
              
                
                ${project.build.directory}/tomcat5x/container
              
            
    
            
              
                start-container
                pre-integration-test
                
                  start
                  deploy
                
                
                  
                    
                      
                        com.jheck.example
                        example-war
                        war
                        
                        http://localhost:8080/example-war
                      
                    
                  
                
              
              
                stop-container
                post-integration-test
                
                  stop
                
              
            
          
        
      
    
    
    

提交回复
热议问题