A new name for unit tests

Posted by Will on Programmers See other posts from Programmers or by Will
Published on 2011-01-03T17:20:06Z Indexed on 2011/01/03 17:59 UTC
Read the original article Hit count: 343

I never used to like unit testing. I always thought it increased the amount of work I had to do.
Turns out, that's only true in terms of the actual number of lines of code you write and furthermore, this is completely offset by the increase in the number of lines of useful code that you can write in an hour with tests and test driven development.

Now I love unit tests as they allow me to write useful code, that quite often works first time! (knock on wood)

I have found that people are reluctant to do unit tests or start a project with test driven development if they are under strict time-lines or in an environment where others don't do it, so they don't. Kinda like, a cultural refusal to even try.

I think one of the most powerful things about unit testing is the confidence that it gives you to undertake refactoring. It also gives new found hope, that I can give my code to someone else to refactor/improve, and if my unit tests still work, I can use the new version of the library that they modified, pretty much, without fear.

It's this last aspect of unit testing that I think needs a new name. The unit test is more like a contract of what this code should do now, and in the future.
When I hear the word testing, I think of mice in cages, with multiple experiments done on them to see the effectiveness of a compound. This is not what unit testing is, we're not trying out different code to see what is the most affective approach, we're defining what outputs we expect with what inputs. In the mice example, unit tests are more like the definitions of how the universe will work as opposed to the experiments done on the mice.

Am I on crack or does anyone else see this refusal to do testing and do they think it's a similar reason they don't want to do it?
What reasons do you / others give for not testing?
What do you think their motivations are in not unit testing?

And as a new name for unit testing that might get over some of the objections, how about jContract? (A bit Java centric I know :), or Unit Contracts?

© Programmers or respective owner

Related posts about unit-testing

Related posts about test-driven-development