Home arrow static arrow Java Programming [Archive] - any JUnit fans here
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - any JUnit fans here
This topic has 18 replies on 2 pages.    « Previous | 1 | 2 |

Posts:50
Registered: 12/9/97
*If* you unit test your code - JUnit is it  
Jun 22, 2004 1:57 PM (reply 15 of 18)



 
This thread seems to be arguing the worth of unit testing. That answer is obvious - on large projects (especially those employing large numbers of developers), unit testing is vital (unless you enjoy frustrating your fellow developers).

JUnit is great for several reasons in such a situation (in decreasing order of importance):

0) It requires no purchase orders, credit cards, or other financial transaction to obtain (monetary contributions are optional)

1) it's a common framework - you can run your Junit tests as well as any other of your team members. If another team member has to work on something you wrote, they should be able to understand your unit test - so not ever developer has their own personalized unit test interface.

2) it's maintained by someone other than yourself (unless you are a code contributor)

3) integrating ant and junit is invaluable for new builds to ensure a basic set of tests is passed before releasing a new build

For those who "code from the hip" or prefer testing at the integration levels, they of course aren't likely to be able to provide very useful commentary on any unit testing platform.

Cheers,
Alexandra
 

Posts:21,719
Registered: 98-02-20
Re: any JUnit fans here  
Jun 22, 2004 2:02 PM (reply 16 of 18)



 
Fowler and the whole JUnit and XP camp are pretty
vocal about writing the tests first, IIRC. I don't
follow that guideline rigidly myself, but I do
generally write the tests quite early--usually after
the code being tested has some skeletal structure, but
before it's complete.

I don't follow that guideline rigidly, either. I try to write them method-by-method, testing "blue sky" conditions, failure conditions, and boundary cases if I can. I make sure that exceptions that I want to see thrown ARE thrown, etc.

%
 

Posts:21,719
Registered: 98-02-20
Re: *If* you unit test your code - JUnit is it  
Jun 22, 2004 2:04 PM (reply 17 of 18)



 
Good points, Alexandria.

I'd also point out that JUnit tests are not system integration tests or user acceptance tests. I see them as a first line of defense, a guarantee from a developer that checked in code does indeed work as advertised.

It does make sure that checked in code compiles. (How many folks have worked on projects where checked in code broke the build?)

JUnit tests can be invaluable as examples of how to use your code. Other developers wanting to know the proper idiom for using your stuff can look at the tests to get an idea.

%
 

Posts:1,657
Registered: 1/8/98
Re: *If* you unit test your code - JUnit is it  
Jun 22, 2004 8:21 PM (reply 18 of 18)



 
Other developers wanting to know the
proper idiom for using your stuff can look at the
tests to get an idea.

I certainly hope not! My Unit tests are usually filled to the brim with the most oddball, out of bounds errors I can think to induce. The "happy path" tests are lost amongst the noise... :D
 
This topic has 18 replies on 2 pages.    « Previous | 1 | 2 |