Solved

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

Posted on 2008-06-22
7
240 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
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now