The World’s Leading Microsoft .NET Magazine
   
 
timstall

Donate Today!

Search Box

 

Calendar

««Mar 2010»»
SMTWTFS
  12
3
456
7
8
9
10
111213
1415161718
19
20
21222324252627
28293031

My RSS Feeds








Mailing List

Most Popular Tags

                                                           

Is unit testing a second class citizen?

posted Friday, 20 March 2009

Especially with the successful track record of unit tests, no project wants to be caught rejecting the notion of "unit testing your software". However, for many projects, unit testing seems like a second-class citizen. Sure, people speak the buzzwords, but they don't actually believe it, hence they diminish unit tests as some secondary thing unworthy of time or resources, as opposed to "real code".

  1. Will developers actually spend time writing unit tests while they develop a feature (not just as an afterthought)?
  2. Will developers (including architects) design their code such that it's conducive to unit testing?
  3. Will a broken test get a manager's attention, or is it just some nuance to be worked around?
  4. When a business logic bug is found, is there enough of an infrastructure such that you could write a unit test to catch it (the test initially fails because the code is broken, then passes once you fix the bug)?
  5. Will developers invest mental energy in learning to write better tests, such as reading blogs or books on testing, or experimenting with better testing techniques?
  6. Will developers write unit tests even when no-one's looking, or is it just some "tax" to appease an architect or manager?
  7. Will management support the hardware for it, like having an external build server with the right software (while NUnit is free, MSTest still requires a VS license)?
  8. Will a broken unit test cause the build to fail?
  9. During code reviews, will other devs review your unit tests, similar to how a QA person reviews functionality?
  10. Do your amount of unit tests increase as the rest of the project grows?
  11. Is the team concerned with code coverage?

tags:  

links: digg this    technorati    




1. Dave Schinkel left...
Tuesday, 24 March 2009 8:05 am

There is one most critical piece to the problem with not enough testing or no testing at all. That is, business buy-in AND manager push-back. How many code & run shops do you see out there that would not even consider adding time to their waterfall timeline? Obviously if you're true Agile, adding unit testing to the sprint is a no brainer and is not questioned because the business must have buy-in to be Agile in the true sense of the word.

So, as I see it as with anything about code quality (and I'm not saying code has to be perfect, that's unrealistic), it typically always comes down to 2 things:

1) Business wants slop and a hack to get it out the door and makes any excuse in the world for that to take place. This compromises many things: a) developers can't learn, because they are continually being rushed b) developers can't think about how they're coding. Are they able to incorporate some SOLID concepts or are they rushed so much that they end up with many points in code that could have been shoved into a method, or methods that are so damn long, nobody can debug them c) bugs found in production instead of with Unit Tests & proper QA

2) Managers in development shops fail to push back and require unit tests and in some sad cases QA. Some shops don't even have QA because they are so small and growing...and that's even more reason to slow down and have freaking unit tests!

So until corporate American wakes up and CEOs chill out, they will continue to pay up later when code breaks, or that system you started 5 years ago (whether it's 3rd party or not) costs you in the long run becuase it's no longer extensible or maintainable due to the code & run environment higher ups constantly and stupidly push downward to cause friction and horrible process in the world of IT.


2. Mock left...
Friday, 27 March 2009 3:35 am :: http://www.typemock.com/index.php

Hey Dave,

Perhaps “Corporate America” didn’t wake up yet, but I can tell you that in Scandinavia (Norway, Sweden, Denmark etc…) unit testing and code quality is considered a must in most companies that I’ve worked with.