Junit Run Configuration with Pattern - module working directory not set when test is run

Answered

Hi,

I have a multi-module java maven project that has the following run configuration:
- Junit run configuration (using JUnit4)
- Test Kind: Pattern
- Pattern: "com.example.Module1Test||com.example.Module2Test" (Tests are located in multiple modules)
- Search for tests: In whole project
- Working Directory: $MODULE_WORKING_DIR$

Module1Test is trying to load a file from "src/test/resources", which is relative to the module root directory.

When I run Module1Test only, the test passes.
When I run all tests in module1 and module 2 (mark both module folders -> right click -> Run 'All Tests'), they all pass
But when I run the Pattern configuration, Module1Test fails, because the working directory is set to the project root folder, and not module1.

I'm running IntelliJ IDEA 2019.2.1 (Ultimate Edition)
Build #IU-192.6262.58, built on August 20, 2019

Some background info:
- I cannot change the project code (not my source code)
- The actual case is an IntelliJ plugin I am developing, which selects a subset of unit tests by a criteria, and creates the above configuration in order to run only the selected tests. this is manually reproducible.

Thanks!

0
4 comments

FYI I have a .zip file with a sample project, not sure how to attach..

0

Hello, 

If possible and convenient please create an issue at YouTrack (https://youtrack.jetbrains.com/issue), you may attach all the information to it privately. Or you may also upload it here: https://uploads.services.jetbrains.com

Thank you 

0

Hello,

Thank you for providing the sample, the issue is reproduced.

0

Please sign in to leave a comment.