Solved

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

Posted on 2008-06-22
7
261 Views
Last Modified: 2013-12-15
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.
0
Comment
Question by:technoparkcorp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:technoparkcorp
ID: 21841513
This is what I found, but looks like Eclipse doesn't follow the guidelines...
http://java.sun.com/blueprints/code/projectconventions.html
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21841751
Quite often tests are found in a top level directory <ROOT>/test
0
 
LVL 3

Expert Comment

by:Sankozi
ID: 21841970
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 21842624
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
 

Author Comment

by:technoparkcorp
ID: 21843914
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
 
LVL 92

Expert Comment

by:objects
ID: 21843928
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
 

Author Closing Comment

by:technoparkcorp
ID: 31469557
Thanks, it helps!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question