Our Java code (not the test code) reads files from the current directory, which means the working directory needs to be set properly whenever we run the code.
When launching a JUnit test from within Eclipse, a launch configuration automatically gets created. The problem is, that the working directory in that launch configuration is always by default the root project directory which is always wrong, the test fails, I have to open the launch configuration dialog, change the working directory and relaunch the test. This is very annoying. The same thing happens when I run a single test method.
I've already considered these:
- Changing the current directory from the test code - not possible by design.
- When opening a file, pass a parent directory parameter - too difficult, since this would affect lots of places.
- Use the Copy launch configuration feature of Eclipse to create new launch configurations from existing ones that already have a correct working directory set. This doesn't really makes sense here, since I would like to launch a test or a test method quickly, just by invoking "run this test / method as JUnit test".
All in all, it looks like it's responsibility of Eclipse, not the code.
Is there a way to set the default working directory for all future, newly created JUnit launch configurations?