I am 99% sure I have had a post like this in the past, but my google-foo was weak today and I could not find it. Do not let anyone blow smoke up your back side, testing is expensive, testing takes time but most importantly testing can help improve the quality of your code.
If you are going to spend the time and money to create automated, rerun-able unit tests make sure you spend your time/money wisely. Make sure you test the code that matters, test the code which is complicated (keep in mind a LOC count does NOT equal complexity).
Today when scanning some code in another part of our project I came across this tests:
public void AdminSetIDTest()
var target = new CreateTaskActivity();
int expected = 50;
target.AdminSetID = expected;
actual = target.AdminSetID;
When I looked at this tests 2 bells immediately went off in my mind
- The name of this tests SUCKS BALLS and does not clearly convey the intent of the test
- This is testing that a property getter works (no, there is NO logic behind the getter/setter)
If you disregard #1 from above for now (but remember clear/concise names do matter) and focus on #2 this tests adds no value to the test suite. All this test is doing is ensuring that the .Net framework does its job. This test is a total waste of time and energy and can actually cost you more time/money in the long run because you may have to change the useless test over time as you refactor.
The key take away from this is simple. You always have limited time and money when trying to get a product out the door. Unit testing IMO can always help you to create a better product, but make sure you use your time and money in a way in which will allow you to maximize your ROI.
Till next time,
10-07-2009 6:48 AM