Solved

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

Posted on 2008-06-22
7
250 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java - Why doesn't this JFrame work 3 59
tomcat administrtor 12 46
Visual Studio 2013 and Eclipse Neon 6 36
maven module vs maven project 3 23
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.
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:

770 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