dimanche 1 mai 2016

Maven test: files created of the test arn't created by mvn test, but with normal IntelliJ Testrunne

I have a project, where we write files during the unittests. They should be written to "target/testData". This works wonderfull if I run the Tests with the IntelliJ Testrunner. If I run "mvn test" it runs succesfully but it doesn't create the Files. Whats wrong?

This ist my surfire config:

<plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <myOutDir>${project.build.outputDirectory}</myOutDir>
                            </systemPropertyVariables>
                            <forkMode>never</forkMode>
                            <workingDirectory>${project.build.outputDirectory}/</workingDirectory>
                        </configuration>
                    </plugin>

The File ist created in following dir:

 private static final String resultDirName = String.format("%s%stestData", System.getProperty("myOutDir"),
            File.separator);

and used like that:

resultDir = new File(resultDirName);
        if (!resultDir.exists() && !resultDir.isDirectory()) {
            resultDir.mkdir();
        }
        if (result != null) {
            String name = "someName
            File resultFile = new File(resultDir, name);
            ImageIO.write(result, "JPEG", resultFile);
        }

Aucun commentaire:

Enregistrer un commentaire