How do I organize directories in my project in Eclipse? Where to put unit tests?

I'm trying to setup a new project in Eclipse and can't understand where unit tests should be located. In /src or in /src/test? In the same package as source code or in different?

Please, give me a brief guidance.
technoparkcorpAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
Create a new source folder in src/test
And within that folder use the same package structure as the classes that r being tested
0
 
technoparkcorpAuthor Commented:
This is what I found, but looks like Eclipse doesn't follow the guidelines...
http://java.sun.com/blueprints/code/projectconventions.html
0
 
CEHJCommented:
Quite often tests are found in a top level directory <ROOT>/test
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
SankoziCommented:
Unit tests are usually in the same package but different directory. In Eclipse you can add source directories in Project -> Properties -> Java Build Path. Create and add "test" directory. When you want to add JUnit test just right-click class  -> New -> JUnit Test Case. In dialog change "src" to "test" and test class will be created in proper directory.
0
 
technoparkcorpAuthor Commented:
I can create JUnit test case in Java Perspective, but I don't have such menu item in Java EE Perspective. Why?

In Java Perspective the solution you offer works, in Java EE Perspective I can't do this.
0
 
objectsCommented:
because that perspective is aimed at j2ee development, ie it is more focussed on the application development rather than the classes (an tests) used by the app.
Easiest is to switch perspectives when working on classes and testing them.

0
 
technoparkcorpAuthor Commented:
Thanks, it helps!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.