Multiple Folders for test cases

My project has two source trees for test classes -- one for integration tests and the other for unit tests.

Should I happen to have a class which requires both a integration and unit test, I am accustomed to naming both of them Test[tested class].java. However, IDEA marks this as an error -- complaining that a duplicate class exists.

This is incorrect, in my opinion. The two test source trees are never compiled or executed together. While I can simply use a new name for the second test class, I don't feel as if my naming scheme should be dictated by IDE behavoir.

Has anyone else experienced this scenerio? Besides using a new class name, are there other workarounds?

~Keith

3 comments

I think that you can work around this by creating the separate project that
depends on the first and putting one test source tree in that one.

--Mike

My project has two source trees for test classes -- one for
integration tests and the other for unit tests.

Should I happen to have a class which requires both a integration and
unit test, I am accustomed to naming both of them Test[tested
class].java. However, IDEA marks this as an error -- complaining that
a duplicate class exists.

This is incorrect, in my opinion. The two test source trees are never
compiled or executed together. While I can simply use a new name for
the second test class, I don't feel as if my naming scheme should be
dictated by IDE behavoir.

Has anyone else experienced this scenerio? Besides using a new class
name, are there other workarounds?

~Keith



0

Keith Collison wrote:

My project has two source trees for test classes -- one for integration tests and the other for unit tests.

Should I happen to have a class which requires both a integration and unit test, I am accustomed to naming both of them Test[tested class].java. However, IDEA marks this as an error -- complaining that a duplicate class exists.

This is incorrect, in my opinion. The two test source trees are never compiled or executed together. While I can simply use a new name for the second test class, I don't feel as if my naming scheme should be dictated by IDE behavoir.

Has anyone else experienced this scenerio? Besides using a new class name, are there other workarounds?


Since I assume you've got the source files as two content roots in the
same module, IDEA assumes that they'll be compiled and ran together. You
should try separating them into two modules.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0

Thank you both for the suggestion.

Given that my project is already 10+ modules, I'm hesitant to create a new module for each integration test suite (making the amount of modules 20+!). Perhaps I'll create two projects -- each containing the module list but pointing to different test source paths. Not a great workaround, as any refactorings performed in one project will miss changes needed in the other's test classes.

I guess this is simply a limitation of IDEA I'll have to live with. I feel as if IDEA's junit integration could be tweaked a bit. For example, I feel like I ought to be able to define libraries & resources that apply merely to test classes and not to the main project.

If anyone else has any suggestions, let me know.

Kind regards,

~Keith

ps. for what it's worth, Eclipse is able to handle this use case.

0

Please sign in to leave a comment.