A Funny Java Flavoured Look at the World

Monday, May 08, 2006

How to persuade Java developers to unit test

I have been trying to persuade/encourage/bully my fellow developers to start Unit Testing. At the moment I'm not have that much luck because they can't see beyond the fact that they would have to write some unit tests and this to them seems like extra work.

I have tried to tell them it makes you write better code with less dependencies.

I have explained you have more confidence in your code when you catch lots of silly syntax errors and know it passes numerous tests.

You are testing anyway, unit testing is just like all those system.out's you are putting in the code except unit testing means you don't have to read them all

unit testing breaks up the sometimes tedious task of writing code, it's good to see that green bar pop up, it is a small victory every time the bar turns from red to green.

Anyway my arguments were falling on deaf ears (they were too busy finding a bug somewhere in their code, MWAHAHAHAA only joking). I find it a bit scary that they are writing code without testing it, especially when you see I know how many small bugs I find.

Anyway whilst noodling about the Aritima site I found the free chapter links and then I found a free chapter on unit testing called "Pragmatic Unit Testing - in Java with Junit"

perhaps they would listen to the words of a good developer and not my cowboy ramblings, it was worth a shot.

The chapter is pretty useful, it's only 14 pages long so it won't scare them or you off. It goes through what Unit testing is and more importantly it has a section called

"Why I should bother with Unit Testing"

if you are already unit testing then it's worth reading the chapter to just have a look at the excuses for not unit testing which will help you realise why you unit test.

So if you need help persuading your fellow developers to start unit testing get them to read this article it might help

http://www.artima.com/getfile/261-53525-78208-20/

5 Comments:

  • You're trying to be too nice. Tell these lame developers to test early and test often. Talk to management to enforce TDD. Far too often people neglect creating 'effective' test cases and the result? A change in business code which causes a change in a method which ... causes logic else where in your project to ... FAIL.

    Lay down the law!

    By Anonymous Anonymous, at Tue May 09, 04:45:00 am 2006  

  • We are in the same boat. We have large applications with almost no unit tests. While most people use the size as a reason not to start putting in tests, I am hoping to use that size to advocate unit testing. Our application can take 15-20 minutes to deploy, when you factor in container startup times and all relevant initializations. When developers only test their code in the container, in a "live" environment, that can be 15-20 minutes of redeploy time wasted every time they want to test. Most stages of testing do not need all of that other code running, and a properly scoped unit test could give the developer what he/she needs in seconds, or at most, a couple of minutes.

    Sure, creating test cases and mocks will cost you some up front time, but, all other benefits aside, they more than make up the time cost by removing all that downtime waiting for deployments. Of course, a lot of developers want to protect that time to go get coffee, but that's another problem...

    By Anonymous Anonymous, at Tue May 09, 06:22:00 am 2006  

  • Many developers write test apps for some kinds of changes anyway, such as with a main() method.

    Just use an IDE with nice JUnit support and ask them to write a test case instead.

    Next step is to validate the results instead of just println them.

    Baby steps and fairly practical for some cases.

    By Anonymous Anonymous, at Tue May 09, 08:59:00 pm 2006  

  • Hallo I absolutely adore your site. You have beautiful graphics I have ever seen.
    »

    By Anonymous Anonymous, at Fri May 19, 08:39:00 am 2006  

  • Looks nice! Awesome content. Good job guys.
    »

    By Anonymous Anonymous, at Fri May 19, 07:05:00 pm 2006  

Post a Comment

<< Home