In my last post (here) I was giving a wrap up of the Mocking session I recently did at TriNug. In that post I gave some of the reasons (sorry, I meant excuses) people gave for not doing any type of automated testing during their dally development ritual (notice I am staying away from TDD at this point). I thought that those topics would be better suited to be broken out into their own post.
At the users group I asked the question to the group 'who creates automated tests as part of their daily development cycle?'. After I asked this question I followed it up with, and if you don't WHY, WHY, WHY, WHY...... Below are some of the answers I received (btw, not the first time I have heard these reasons).
Reason #1 - It is too hard to get started:
Point: This statement is nothing new, I hear this all the time. To be honest I agree with them, testing is hard. It takes time and effort to learn how to do it.
Counter Point: But if you think learning to write tests and learning how to create testable code is hard, then what do you do when you need to learn a new product? I can break it down like this. Testing == Coding and Coding == REAL FREAKING HARD. Stop using 'testing is hard' as a crutch and just give it a shot.
Reason #2 - My client/company is not paying me to write tests:
Point: This one always make me laugh. Since testing does take time (not going to sugar coat this at all), and can slow down your pace of development, many people feel that they are not being paid to create tests.
Counter Point: This one is real simple, ask your self these two questions.
- Am I being paid to produce quality or crap?
- Am I being paid to debug?
I am going to assume that both of those answers are NO, and if they are not then I would suggest you stop reading this post as it does not get any better from here.
Now that we are on the same page and we understand you are being paid to produce quality code why would you not want to do everything you can to bake that quality into your code up front? This can happen with tests. Take the time, take the challenge and create some tests. Trust me, no one ever got fired for being a bit late with an application that was freaking solid from a quality standpoint (and if you do get fired because of it just look at it this way, you have a new and marketable skill to help you find your new job).
Reason #3 - I do not have time
Point: Testing takes time, and when time is short people throw every 'non-critical' functions out the window. And sadly people think that quality is a non-critical function. To prove this point just take a look at 90% of the applications out there... they suck ASS
Counter Point: Just ask yourself this question. Would I rather spend what little time I have creating tests to help ensure I have quality or would I rather spend time later stepping through code via the debugger looking for the bug I could have caught/fixed earlier? If you would rather spend time in the debugger, then more power to you.
NOTE: Do NOT take the above statement as me saying that testers NEVER debug, they do but just a TON less than others.
Reason #4 - My code will not allow me to tests
Point: This is one may be the only excuse that has some merit. Poor code is hard to test.
Counter Point: Simply because you do not need to retrofit your entire code base at one time. If you have 'bad' code that is easy to test that is fine. Start testing with NEW code. Hopefully you will not be creating bad code once you understand your current code is not the best. You will also come to understand that when you start testing your code will start to get a little cleaner. Finally, if you really want to start to test your legacy code, go out and pick up 'Working Effectively w/ Legacy Code' by Michael Feathers
As you can tell from my tone, I do not buy into any of these reasons, sorry excuses. I wish that when I ask people this question and they gave me a response they would simply state the truth. And the truth is people do not test for the following 2 reasons
Reason #1 - They do not believe that creating tests will improve their code
If this is what you really think, that is fine. You are allowed to have your beliefs and I am allowed to have mine. As long as we understand each other we can get along just fine.
Reason #2 - They are lazy
Not sure I need to explain this one.
Let the flames begin :)
Till next time,
11-14-2008 5:58 PM