weblog.masukomi.org

mah-soo-koh-me

 

I think I know why people don’t value tests May 25, 2007

Filed under: Uncategorized — masukomi @ 8:52 pm

I think I understand why people tend to not write tests. Because they believe
that tests aren’t something that’s either needed or important.

 

“Duh,” I hear you say, but bear with me.



Why don’t people believe that tests are something that’s either needed or
important? Well, I think one of the biggest contributing factors to WHY is that
essentially zero of the learn to program in language FOO books ever mention unit
testing. Unit testing has been around in a formal sense since
the
creation of SUnit back in 1994
! 1994 I say!
That’s thirteen years now. Thirteen years and I could probably count on
one hand the number of introductory language, or language reference, books that
not only mention unit tests but actually explain why their important and how to
use them. Even worse, most languages don’t have unit tests tools built into
their core libraries. All the modern languages have fairly comprehensive test
coverage but they have to use external tools to write those tests. How crazy is
that? We have this common programming task that we all agree is
critical to releasing a stable version of
the language but it’s not important enough to build
into the language.  Wha?!?! 
The end result is that since we don’t teach tests as being even noteworthy when
teaching a language no-one learns that they are important. For the most part
people just don’t seem to understand the value of tests until they’ve been in
the industry so long that their feet are riddled with
holes.[1]



Mike Clark, and others, suggest
writing
“Learning Tests”
as a way, not only to learn a new language, but as a way to
accrete a repository of what you’ve learned about a language. I think this is a
GREAT idea. Imagine if every book that taught a new programming language showed
you not only how to do something but then followed it up with how to confirm
that you didn’t screw it up by demonstrating how to write a test for it? People
would start to see test writing as a standard part of the software writing
process. It would be “just what you do.”



Imagine the impact that including unit testing as a standard part of the
learning process would have on the software industry! Sure it might take five to
ten years before we started to see the results from it but wouldn’t it be worth
the wait?



[1] From having shot themselves in the foot on many prior
occasions.

Popularity: 4% [?]

 

1 Comment for this post

 
Says: April 8th, 2008 at 3:32 pm

There’s also the issue that testing in some languages is just a pain in the behind…

I love unit testing. I can’t justify the overhead of at least *constant* testing in C++, even if I take into account the time spent on hunting bugs.

Nightly tests are more likely, but with the brittleness of C++ APIs, you spend more time rewriting to API changes than actually writing tests.

Throw into that the nightmare that is WTL, and unit testing becomes prohibitively hard.

I’m still looking for a unit tested real-world C++ application so that I can learn how to do it better, but *all* examples I’ve seen test only trivialities - and never uncover the things that actually break.

Leave a Reply