gradle, multimodule project - TestNG test run in a module create paths in project root

Hi. For the following gradle project structure:

     - Module1
     - Module2
     - Module3

when I run a test in Module1 IDEA that creates a file like this:
new File('some_directory')

it is created as ProjectParent/some_directory, not ProjectParent/Module1/some_directory. The latter works fine on the command line with gradle, independent of whether I run the test from the module folder or from the top level project folder. I would expect IDEA to do the same.
Now, I can change the working directory for each run configuration separately, but this is a little annoying. How can I fix this once and for all, for all modules?
I tried editing the default TestNG configuration and chose the $MODULE_DIR$ variable there, but it is still the same - still wrong, as if this setting wasn't taken into account (does it only work for maven?). Please note that I created the new test run config after I edited the template, and double checked that the setting is defined for the run config in question. I found this:

This is for maven, but I think it is the same for gradle, as it actually has nothing to do with the build system, it is the TestNG run config that doesn't work. But, the $MODULE_DIR$ workaround found elsewhere doesn't help. What am I doing wrong?


Please sign in to leave a comment.