Welcome to MSDN Blogs Sign in | Join | Help

Progressive Development

Zany Adventures in Software Engineering with Maven and Motley
Motley says: "I am a developer - I don't test. Testing is for the test team."

Summary

 

Motley: Unit testing is the test team's job! I am not paid to write tests.

 

Maven: White box (unit) tests help with code quality and give you confidence to change your code.

______________________________

 

[Context: During a previous conversation about debugging, Motley stated that he doesn't do unit testing]

 

Motley: Yeah, that's what I said: unit testing is the test team's job! I am not paid to write tests.

 

Maven: Did you know that unit testing is a developer technique with one of the biggest returns on investment?

 

Motley: Great. But it's still not my job. We hire a test team. They test. That's what they do.

 

Maven: But does the test team know the code the way you do? Unit tests need to be white box tests - they exercise as many code paths as possible - ideally, all - and require knowledge of the code.

 

Motley: Testers are technical people - they can figure it out.

 

Maven: But, they have a lot of other stuff to do. The test team has to do performance testing, stress testing, integration testing, platform testing, and of course, the all-important testing of real customer scenarios. Do you think they have time to find all those trivial little bugs that you should have caught before check-in? The answer is NO! The have expectations that developers write high quality code. They then do the validation of the code with test scenarios that would be difficult for developers without a full infrastructure to test.

 

Motley: They're also the reason why our ship dates are often missed!

 

Maven: Only because the developers are not doing their job with unit testing. You need to do a root-cause analysis on why we have these long "stabilization" cycles. We should not be stabilizing anything! As of our code complete milestone the code should be stable. The Test team validates on the black box level - without having knowledge of the code - to ensure integrated scenarios work properly.

 

Motley: So you're saying that developers need to write test code??? Bah!

 

Maven: YES! Try it on the unit level. In the object-oriented world, a unit is often a class. Write a set of tests using a unit test framework that exercises the contracts of your methods. Run them as often as possible - ideally, after every code change. By having tests in place, you have the confidence to change your code without breaking anything. Plus, you can generate code coverage numbers to help validate the thoroughness of your tests. The test team will thank you because now they can focus on their real jobs and not cleaning up after the developers. The test team also gets some nice sample code that helps them learn more about your APIs.

 

Motley: Sounds like lots of benefits to have unit tests, but I am still not totally convinced. If I take care in writing my code and ensure it's bug-free, test can still concentrate on doing their real jobs.

 

Maven: But you can't be sure your code has minimal bugs until you test it! Honestly, if I could get devs to add one technique to their quality arsenal, it would be unit testing.

 

Motley: Tell you what: I'll give this thing a try. However, if I don't get positive feedback from the test team that it is helping, I'm going to return to writing real code and let them figure out if my stuff works.

 

Maven: I'm good with that. I think you'll come out a winner! In the future we'll talk about this idea of contracts and code coverage, but start with some basic tests.

 

Motley: I really look forward to that conversation - kind of like a cat looks forward to being neutered.

______________________________

 

Maven's Pointer: These days, Microsoft hires testers that are just as technical as developers - they just have a different role. However, since developers know the code in detail, they need to be the ones to test the details. The test team can validate the code on a higher-level to ensure integrated scenarios function correctly. By combining the test responsibilities, we ship sooner and with higher quality.

 

Maven's Resources:  Pragmatic Unit Testing in C# with NUnit, by Andy Hunt and Dave Thomas, Pragmatic Bookshelf, ISBN: 0977616673, 2007.

Posted: Thursday, March 29, 2007 8:56 AM by James Waletzky
Filed under: , ,

Comments

Joe Chung said:

As a developer, I'm convinced of the value of testing, but you're preaching to the choir.  Try developing compelling arguments that would convince managers of the value of testing.

# March 29, 2007 1:36 PM

James Waletzky said:

It's great that you are convinced of the value of unit testing - the practice is definitely effective.

Unfortunately, I run across developers all the time who believe testing is for the test team, and it takes a lot of convincing to have them change their mind. At Microsoft, it's now part of a developer's career responsibilities to do unit testing. That helps set expectations and convince the authoritiative personalities as well as managers. As a dev, you do not advance if you do not unit test.

To convince a manager, you first have to know what they value. Is quality first and foremost or is it delivery time and features? If quality is first, the argument is easier. If he/she is a facts-based personality, there many studies and metrics describing the value of unit testing. I can try and dig some up for a later post if you like. If they are risk adverse, have them try it on a small component/feature and compare the results to other teams that are  not unit testing. Several groups in MS have done that and the quality improvements are significant.

If the manager is feature or time-oriented, it is a bigger challenge to convince them of the value of unit testing. The team probably has bigger problems than just unit testing in that quality is pushed downstream in the cycle rather than up. Also, sometimes it's better to ask for forgiveness than permission. I did this once on a prototype (adding unit tests) and ultimately convinced my manager it was a good practice even on throw-away code. I could easily adapt to requirements changes in the prototype without breaking stuff all over the place.

Thanks for the comment. It is definitely a worthwhile observation to make. Let us know if you have other thoughts!

# March 29, 2007 2:02 PM

Progressive Development said:

Summary Motley: There is no harm shortcutting a few steps of development to meet a deadline. Some up-front

# April 22, 2009 1:27 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker