gbishop
gbishop

Reputation: 25

Set JUnit 5 workingDir for tests

We are in the process of upgrading all of our tests to use JUnit 5. Previously we had to set the test.workingDir so that our tests would work the same in Eclipse and Intellij IDEA. Now that I'm using JUnit 5 I'm running into issues with this. I've gone through the JUnit 5 Gradle documentation, but have found no way to set the workingDir for the tests. This causes issues because the tests run differently in the IDEs than they do in the command line.

Upvotes: 1

Views: 810

Answers (1)

Vampire
Vampire

Reputation: 38639

That Gradle plugin adds a task of type JavaExec called junitPlatformTest. So configure it using junitPlatformTest.workingDir = ....

Besides that, you should maybe rewrite your tests to not depend on the current working dir, but using classpath lookup to get files you need with methods like getResource() and getResourceAsUrl().

Upvotes: 2

Related Questions