JUnit does not pick up test resources first in Intellij IDEA 2017.3.2

Answered

I have a maven-based java/scala project. There is a persistence.xml in src/main/resources for prod, and a persistence.xml in src/test/resources for unit test. The one for prod connects to a mysql env, and the one for test connects to a in-memory db. After a build, I can see the prod one goes to targets/classes and the test one goes to targets/test-classes.

However when I run unit test in Intellij, the program always connects to mysql env instead of using the in-mem db. I think the unit test did not respect a correct classpath order to put the things in test/resources first. 

My temporary solution is to rename the prod one as "persistence.xml.prod", and rename it in maven build. However I think this is sloppy and would like to know the correct way of handling this in Intellij. Thanks!

0
1 comment

Please file an issue at https://youtrack.jetbrains.com/issues/IDEA with a sample project to reproduce attached.

0

Please sign in to leave a comment.