Maven: change the directory in which tests are executed

前端 未结 1 1558
死守一世寂寞
死守一世寂寞 2020-12-11 00:30

In my code I have set to create some files in ./ directory, because when the software will be deployed in the installation machine, all the configuration files

相关标签:
1条回答
  • 2020-12-11 00:38

    If you are using the surefire plugin to execute tests (which is the default), then you can set working directory like this:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <workingDirectory>${java.io.tmpdir}</workingDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    Reference: http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html

    To set to the specific directory in the question:

    <workingDirectory>${project.build.directory}/test-run</workingDirectory>
    
    0 讨论(0)
提交回复
热议问题