Default (JUnit) working directory per module

Hi Guys,

I know this has been discussed before, but it seems to have dissappeared off the radar, which is a shame because i always run into it.

My problem is that i have a project with multiple modules; and my unit tests typically reference data files under the module which own the tests.

These references are usually relative to the module root;

e.g. structure

ProjectX
-ModuleA
+-src
+-test
+-src
+-data
-ModuleB
....

From a test case, i would like to load a file from "test/data/testDataFile.txt" - but this doens't work in multi-module prjects, i would have to reference it "ModuleA/test/data...", unless i specify the default working dir per package/class/method.

What i would like to do is to set the default working directory for each module. That way i dont have to edit lots of run configurations, but i cant see a way to do that!

Whats the general consensus here, have people come accross this problem before? Do you not reference files relative to the module? If not, then how do you reference test files?

I dont want to have to reference relative to project root, because you should be able to import the module into different projects and directory names, and still have the tests run, IMHO.

2 comments

Hello Marcus,

ME>
ME> What i would like to do is to set the default working directory for
ME> each module. That way i dont have to edit lots of run
ME> configurations, but i cant see a way to do that!
ME>

I also solve this by editing the run configurations (not much pleasure there).
Is there a tracker request, so we can vote for it?

Best,
Andrei


0

There is: #32653, though doesn't seem to be any activity on it

0

Please sign in to leave a comment.