Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2005

Tip: Looking for answers? Try searching our database.

Q: How to organize unit testing

Thread view: 
Casper B - 24 Apr 2005 16:06 GMT
If I have a custom library formed by a package hiarachy build over the
years, what is the usual way of organizing JUnit testing?

Placing a suite in every package which wraps test case classes is messy
and pollutes the library when deployed as a jar.

I see two possebilites, either separate the tests by the use of
preprocessor build directives (but Java has none right?) or create a
mirror of the library package structure where only the tests live. Which
is the common practice and what problems should I look out for?

Thanks in advance,
Casper
Raymond DeCampo - 25 Apr 2005 01:45 GMT
> If I have a custom library formed by a package hiarachy build over the
> years, what is the usual way of organizing JUnit testing?
[quoted text clipped - 6 lines]
> mirror of the library package structure where only the tests live. Which
> is the common practice and what problems should I look out for?

Personally I prefer to keep the test classes in a separate directory one
way or another.  Unless the tests depend on package visible member items
 in the original classes you can keep them in a separate package.

I recommend looking into using ANT (http://ant.apache.org) for building.
 ANT is capable of doing the build the way you want it (one way for the
regular classes, another for the test classes).  Further, ANT has
special junit directives that make it possible to execute your JUnit
classes without having to build special suites.  ANT is capable of doing
all this in a generic, parameterized fashion, meaning you can reuse the
build scripts for other projects.

HTH,
Ray

Signature

XML is the programmer's duct tape.

Arne - 25 Apr 2005 04:52 GMT
> > If I have a custom library formed by a package hiarachy build over the
> > years, what is the usual way of organizing JUnit testing?
[quoted text clipped - 23 lines]
>
> --

Also quite many of the IDE's out there support JUnit directly in the tool.
We've used both NetBeans and Eclipse, and they both support JUnit directly.
Netbeans separates the tests, like Ray recommends, in a package called test,
with sub-packages reflecting the package hiarachy of your classes to be
tested. Also, NetBeans uses ANT as a project- and build tool, and best of
all: it's free :-)

Arne
Casper B - 25 Apr 2005 14:49 GMT
Thanks a lot for the answer!

Casper


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.