473,473 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Q: How to organize unit testing

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
Jul 18 '05 #1
3 6175
Casper B wrote:
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?


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

--
XML is the programmer's duct tape.
Jul 18 '05 #2

"Raymond DeCampo" <no****@twcny.rr.com> wrote in message
news:g4*****************@twister.nyroc.rr.com...
Casper B wrote:
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?


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

--


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
Jul 18 '05 #3
Thanks a lot for the answer!

Casper
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hugh Cowan | last post by:
Hello, I don't program full-time (anymore), but I do try and stay on-top of the latest technologies and like most are always trying to upgrade my skills and remain current (as much as is...
11
by: rhat | last post by:
Hi Everyone, I've recently been reading some articles about unit-testing in Python , but I am a bit confused: where do I go to get started with this? I tried googling for "unittest" but all I've...
14
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
4
by: Peter Rilling | last post by:
Does VS.NET 2005 Professional support integrated unit testing, or is that only with the team system?
72
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: ...
4
by: Dat AU DUONG | last post by:
Hi, I am new to Unit testing, could you tell me where I could find information (hopefully step by step) and what is the benefit of unit testing. I am a sole developer in a company, therefore I...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
48
by: Ark Khasin | last post by:
Unit testing is an integral component of both "formal" and "agile" models of development. Alas, it involves a significant amount of tedious labor. There are test automation tools out there but...
5
by: Ben Finney | last post by:
Howdy all, PEP 299 <URL:http://www.python.org/dev/peps/pep-0299details an enhancement for entry points to Python programs: a module attribute (named '__main__') that will be automatically called...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.