Saturday, May 01, 2010

Did the test really pass?

I thought I would share a quick experience since I had not posted in a couple of weeks.  Last Friday I had my head phones on and fingers flying on the key board.  I have been really pumped to write code because my coworker has shifted my paradigm from hacking to test driven development.  I am still learning this approach but I feel it is the right approach and more importantly FUN!

So I created some factories that managed the data.  I created some tests against the factories to validate that the tests would get the correct data from the factories.  I then wrote a data driven script.  The script iterates through numerous key words and performs a comparative test between the UI and the back-end XML generation.

When I was done every test passed with flying colors.  I was stoked.  The next morning it occurred to me that perhaps I should test a negative condition and force the test to fail.  I fed the script all kinds of data that should have resulted in a failure.  The test passed every single time.  What the heck is going on?

After a long pause I recognized that the URLs and http requests I was building were flawed.  It was time to consult the client.  After a couple of quick questions the requests were corrected and the test script worked as expected.

So the lesson I share with you is always and I mean always do a karate chop on your test in order to make sure it fails when it is expected to fail.

Continue to chop the code!