How to add persistence.xml to classpath for testing

I have an ant build target that creates a test-build directory containing source code and the persistence.xml used to run my unit tests.

Sorry for the total newbie question, but how do I tell IntelliJ to either:
a) look in this test-build directory for the persistence.xml; or
b) look in another existing location so that I don't have to run this ant task.

If I add the whole test-build directory as a Dependencies -> Project Library -> Attach JAR directories then it finds it but also complains about duplicate classes (as now the classes exist on the classpath twice)

If I only add the test-build/META-INF directory then my unit tests can't find it.



1 comment


For example, the following module structure works for me:

.../module-1/ : module content root
.../module-1/src/ : module source root
.../module-1/scr/org/blah/pack1/... : sources
.../module-1/test/ : module test source root
.../module-1/test/org/blah/pack1/... : test sources

Also you may need some special persistence.xml for test like:
.../module-1/test/META-INF/persistence.xml (didn't try it)

Adding module sources or module compiled classes to dependencies of the same module is not reasonable and may cause problems.

But you run an ant task to create special test directory with sources. Maybe, it's really necessary for you to *create* this directory in runtime - I just don't know.



Please sign in to leave a comment.