How do I specify a separate maven goal for running (Cucumber) acceptance tests?

前端 未结 2 2084
梦如初夏
梦如初夏 2021-02-13 11:21

I have the following project structure:

MyProject
   --src
   --test
      --acceptance
         --step_definitions
         --features
      --unit
2条回答
  •  Happy的楠姐
    2021-02-13 12:09

    The other answer suggested modifying your folder structure to have shared folder for integration and acceptance tests, but you can have the original folder structure as well. Also you mentioned in the comment you want to keep all three (including not-mentioned integration tests) separate, which is possible, though hackish.

    Since you seem to have test/unit for unit tests and test/acceptance for acceptance test, I'm assuming test/integration for integration tests.

    
        
            acceptance-test
            
                
                    
                        
                        maven-failsafe-plugin
                        2.12
                        
                            test/acceptance
                            
                                **/*Acceptance.java
                            
                            
                                **/*IT.java
                                **/*Test.java
                            
                        
                        
                            
                                
                                    integration-test
                                    verify
                                
                            
                        
                    
                
            
        
    
    
        
            
                org.codehaus.mojo
                build-helper-maven-plugin
                1.9.1
                
                    
                        add-test-source
                        generate-test-sources
                        
                            add-test-source
                        
                        
                            
                                test/unit
                                test/integration
                                test/acceptance
                            
                        
                    
                
            
            
                org.apache.maven.plugins
                maven-surefire-plugin
                2.12
                
                    test/unit
                
            
            
                
                org.apache.maven.plugins
                maven-failsafe-plugin
                2.19.1
                
                    test/integration
                
                
                
                    
                        
                            integration-test
                            verify
                        
                    
                
            
    

    Note though that separation only applies for sources: compiled files will all go to the same folder, and AFAIK that's something you can't change. This means you need to have naming strategy for your tests to separate them from each other.

提交回复
热议问题