Maven – Add directory to classpath while executing tests

You can also add new test resource folders.

<build>
    <testResources>
        <testResource>
            <directory>${project.basedir}/src/test/resources</directory>
        </testResource>
        <testResource>
            <directory>${project.basedir}/src/test/something_else</directory>
        </testResource>
    </testResources>
</build>

The first path, src/test/resources, is the default. Assuming you still want the default path to be used, make sure it’s included. (The testResources tag overwrites your defaults, so if you don’t include the default path explicitly, it will stop being used.)

Leave a Comment