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
Solved

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

Posted on 2008-06-22
7
256 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

789 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