maventestingmaven-surefire-plugin

Surefire doesn't execute tests from the test output directory on higher maven 3.9.6 version


I have upgraded maven from 3.5 to 3.9.6. I have changed no other configuration in my pom.xml or upgraded the surefire version as of yet.

The surefire config in my project pom.xml looks like this:

<build>
    <sourceDirectory>src/main/someCodeFolder</soureDirectory>
    <testDirectory>src/test/someTestFolder</testDirectory>
    <testOutputDirectory>target/mytests</testDirectory>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

When running tests previously, they would be executed from a lib/lib-component/target/mytests level.

Ever since upgrading to maven 3.9.6, tests fail as some of my path references have ../dependency/xyz as it's expected to run from within the target/mytests level.

I know I should use absolute paths, but in this instance, what has changed/could have changed in the 3.9.6 env configuration resulting in tests being executed from the library level, as opposed to the test output directory level?


Solution

  • FYI, I solved this using the workingDirectory option on surefire.

    Added

    <configuration>
        <workingdDirectory>target/test-classes</workingDirectory>
    </configuration> 
    

    to the pom xml for the plugin.