wood burning stoves 2.0*
The moose likes Testing and the fly likes JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit "watchdog": does that exist?" Watch "JUnit "watchdog": does that exist?" New topic
Author

JUnit "watchdog": does that exist?

Joe Toug
Greenhorn

Joined: Mar 24, 2006
Posts: 3
Hi all,

I will have to implement Unit Testing in our existing source code soon. Since it is quite big there's a lot on my plate!

We are 5 people working in my team and I'd be quite upset if some of them were changing the code without updating the tests as well, thus ruining my efforts.

Is there any kind of "watch-dog" plug-in that would warn my teammates that the code they are currently changing has a related JUnit test? Even better, something that would prevent from saving unless the unit test is updated. (Yeah, I might be dreaming... :roll: )

Thanks all!
Joe
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24185
    
  34

Hi Joe,

Welcome to JavaRanch!

You're not dreaming at all: or at least, your dreams have come true! There are a number of ways to do what you want.

First, and most important, you have to be using version control software to manage your source. You're doing that already, right? If not, that's your first task. Set up Subversion or CVS, and get your sources into it.

Now, the fun starts. There are two basic approaches:

1) Use check-in scripts (scripts that run whenever someone tries to check in their changes) to run the tests automatically. If the tests fail, reject the checkin.

2) Use a continuous integration tool like CruiseControl which will, each time someone checks in changes, run all the tests, and send everyone email to complain if the tests fail.

If all this is new to you, it might be hard to see how the pieces fit together at first. There are several great books on the topic -- I enjoyed this one.

Good luck, and c'mon back to the Ranch and ask for help if you need it!


[Jess in Action][AskingGoodQuestions]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
There also is an interesting Eclipse plugin that runs all the tests as part of the build: http://pag.csail.mit.edu/continuoustesting/

But as nice as those tools are, what you really need to tackle is the attitude of the team. It might be better to use a manual continuous integration process than a tool like Cruise Control: http://www.jamesshore.com/Blog/Continuous-Integration-is-an-Attitude.html

See also http://www.xp123.com/xplor/xp0203a/index.shtml

They need to understand that keeping the tests up to date is their responsibility. They even should write their own tests for new code.

Why is it that you are responsible for writing those tests in the first place?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joe Toug
Greenhorn

Joined: Mar 24, 2006
Posts: 3
Hi guys,

Thanks for those valuable answers and for the warm welcome!

I am responsible for the tests because I agreed with my manager to put them into my yearly objectives. The code we maintain has been created a few years ago and no unit testing was implemented by then.

We are using Perforce as our integration tool. I don't know if it is possible to run "check-in scripts" with that application, but it is definitely worth checking!

Glad to be part of the ranch!
Cheers!
Joe
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Joe Toug:
I am responsible for the tests because I agreed with my manager to put them into my yearly objectives. The code we maintain has been created a few years ago and no unit testing was implemented by then.


Get a copy of Michael Feather's "Working Effectively with Legacy Code".

If I were you, after starting to get a feeling for writing the tests, I'd try to do a lot of pair programming with the other developers. Especially if someone breaks one of your tests, I'd insist that they fix it with my help.
Joe Toug
Greenhorn

Joined: Mar 24, 2006
Posts: 3
Originally posted by Ilja Preuss:

If I were you, after starting to get a feeling for writing the tests, I'd try to do a lot of pair programming with the other developers. Especially if someone breaks one of your tests, I'd insist that they fix it with my help.


Very good proposal. We already do a bit of pair programming, but I will insist on doing some more.

Thanks!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit "watchdog": does that exist?