Maven - Add directory to classpath while executing tests

后端 未结 6 1151
北海茫月
北海茫月 2020-12-02 15:29

The Junits I have in my project need to load property files from the classpath. How can I specify the directory of those property files so that Maven will set that in the cl

6条回答
  •  温柔的废话
    2020-12-02 16:00

    You can use the build-helper-maven-plugin to specify additional test-resource directories as follows. Using the configuration below, the contents of the test-resources directory will be copied to the target/test-classes directory during the generate-test-sources phase:

    
      org.codehaus.mojo
      build-helper-maven-plugin
      1.12
      
        
          add-test-resource
          generate-test-sources
          
            add-test-resource
          
          
            
              
                path/to/additional/test/resources
                
                  **/folder-to-exclude/**
                
              
            
          
         
      
    
    

提交回复
热议问题