Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Casey Charlton - Insane World

Hang the code, and hang the rules. They're more like guidelines anyway


Testing Is Not Technically Hard, It Is Hard Because It Requires Clear Thought and Understanding

This whole "lets make TDD easier for the masses" thing is getting out of hand.

Unit tests are not technically hard, as Udi points out, what is a test? Anything with TestFixture on it?

It is not a technical challenge to write a unit test, any half trained monkey could do it. A few attributes, a couple of classes, a few new() statements, and a few Assert statements. We don't need magic mocking frameworks, we don't need any mocking frameworks for 90% of our tests, we don't need application of 12 GoF principles before we can write a test, honestly.

Testing and writing automated tests is hard because it requires a strong understanding of the user stories that sit behind your code and project, because it requires you to think as a user and not as a developer, and because it requires you to be able to think of multiple conflicting axioms, test cases and class interactions, and how to cover the weaknesses of each individual test with other complementary tests.

Bad tests have no value - none. The only "value" that matters is "business value", and a bad test will not reduce your development time, nor will it reduce your maintenance time ... in fact quite the reverse, bad automated tests will require significant maintenance themselves, will force your code to become rigid and resistant to refactoring to a better code base, and give people relying on your tests as a form of usage doumentation totally the wrong ideas, or worse still confuse the hell out of them.

A project with no automated tests is verifiable by observation and UAT. A project with bad automated tests can still be verified by UAT but will now be complex to refactor or fix when problems or bugs appear. A project with a few key *good* tests around *key* functionality will provide a good balance of verification and sanity checking, and still allow the project to be maintained later.

By all means start writing unit tests, but make them Spikes, and you will soon see how your Spikes project becomes fixed in time, with most of them not working after a few weeks of development - now imagine they were automated tests you were maintaining ... /shudder

I can teach someone every part of SOLID they need to be able to write a technically competent unit test inside a day, teaching them how to write tests that have value takes months or years, there is no substitute for experience - but gaining that experience on your employer's time is only valid when the business says it has value to them, and when they understand it will result in a significantly longer delivery schedule - otherwise pay some good testers to do what testers do very well.

Morning rant over, your normal service can now resume.

 


Published Oct 01 2008, 09:46 AM by Casey Charlton
Filed under: ,

Comments

ISerializable - Roy Osherove's Blog said:

The discussion on the future of unit testing for the masses has shifted from the standard “if they are

# October 1, 2008 9:27 AM

Dew Drop – October 1, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop – October 1, 2008 | Alvin Ashcraft's Morning Dew

# October 1, 2008 10:27 AM

2008 October 02 - Links for today « My (almost) Daily Links said:

Pingback from  2008 October 02 - Links for today « My (almost) Daily Links

# October 2, 2008 3:59 AM

Kevin Berridge said:

Hear hear!

# October 2, 2008 1:26 PM

Integration testing in maven - With Maven, Cargo, httpunit and Selenium — andrewmccall.com said:

Pingback from  Integration testing in maven - With Maven, Cargo, httpunit and Selenium — andrewmccall.com

# October 14, 2008 8:27 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Casey Charlton

A somewhat passionate and opinionated developer, with occassional sparks of wisdom, and occasional useful information. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With