where to put testcase source code: under same as application's source?


Where do you recommend putting my junit source code packages in relation to the project that it tests? Currently, I have them in 2 completely separate src directories, built via ANT. This ensures that I don't accidentally import test cases into my production application, but it also makes writing and using test cases tedious.

I know people do it both ways in the general junit community, and I suppose that most IDEA users would put their test cases in with their code, but I wanted to check with the IDEA community how they do it.




Personally, I do as you do, with two separate directories. IDEA (at least the EAP) support this nicely, with concepts of source and test directories. You can either build via Ant, or IDEA's internal build will compile them separately (first source, then test). Additionally, there's a lovely plugin called JUnitTest which makes navigation between a source file and a corresponding test file a one-keystroke operation, if you've got things set up as you describe. Between those, it's about as easy as can be imagined.


After my post I toyed around with more settings and found as you suggested that setting the project properties appropriately makes both source trees available very nicely.
Thanks for the plugin tip too.



Please sign in to leave a comment.