How much testing is enough testing?
If for example, you have to deliver a piece of software, some functionality and you have tight deadlines to meet, is 50% of code tested sufficient enough? How do you know that you have tested the most likely to fail 50% of the codebase?
That question probably sounds quite silly, but whenever I mention to people that they should be using Mock objects to test, they say that it is overkill, and that unit tests are enough. Further probing often reveals that these unit tests are really integration tests, tests such as ask for a particular record, or match filter to return records, and if records are returned, the test correctly passes.
That sort of a test is as brittle, weak and unknown a code fragment as the code fragment that it actually tests.
The database goes does, is that a code failure? Bet there's no test for the server actually going down, and if there was, how would you be able to descriminate between an infrastructure problem, and a coding error?
There are two approaches, one is to write tests, using MSTest, NUnit or whatever else you like to use, you pass a value, and expect a given response. This situation makes it incredibly difficult to test all of the code, since you have no way to control flow through a particular code branch. An example would be testing the exception handling block of a routine, given a unit test, there is no way to inject the exception into the code, so you're stuck with compiler switches to throw exceptions. Compiler switches is changing the code from what it will be in production to something else, which carries its own set of risks.
The alternative is Mocking. Now the concept behind mocking is that you create objects that are effectively proxies to the interfaces that a particular method or class uses. You then set expectations on those objects, and tell them to return data, which effectively drives the code through the desired execution path.
In that instance, if the database goes down, the tests will still pass, you are just driving the interface that is implemented at the data layer. You can't be touched, nobody can take that code down.
As a shortcut, to achieve that deadline, how much time would it take up to consistently and continually test and retest the code with such rigour?
Another question you will be asking yourself, is, is 50% tested code enough now, and will it actually take me less time to resolve all the bugs in the code using the debugger continually, instead of having repeatable and isolateable test targets to check instead?
Keep an eye out for a further article on how to do some mocking to enable the test coverage statistics to get up into the 90% area with nearly all classes.
Monday, February 11, 2008
Making a mockery of Testing
Monday, November 5, 2007
Certifications (MCTS, MCPD, MCSD, MCAD, and so on)
Well, the question is, are certifications, such as MCSD, the new MCTS qualification, and the MCPD qualification worthwhile? Do they offer anything in the way of learning new things, and do the prove to the wider world that the qualified do indeed know more than the unqualified?
Personally I did an MCSD back in 2001, and at the time found the desktop and distributed parts to be a case of learning minute detail to be able to pass the exam. The exception, and useful parts were the "analysing requirements and defining solution architectures" exam, which was a real challenge, and meant to me that you really needed to know your stuff. Personally, I think it's a shame that that exam isn't still available.
Having passed the MCSD back in 2001 I gave myself 6 months off, after which I planned to start studying again. So, after a 6 month break that quickly turned into six years, I'm back again doing some certifications.
At first, whilst studying the MCTS exams, I found that most of it I already knew, just that the names had changed. However, I was gladly surprised to find that there was enough tested knowledge in there to make it worth my while studying for it.
I would recommend that the MCTS exams are aimed at your bog standard developer, so if like me, you've done that sort of thing for some time, you will probably not find it a huge challenge. That said, as mentioned earlier, I believe that there's enough coverage in there to allow you to learn new things, and improve your breadth of knowledge.
Will sitting these exams leads to more opportunities when looking for employment? Almost certainly, if it's between yourself and someone who doesn't have any certifications, I know which one I'd choose, all else being equal. That's the key, if you have the experience, this adds to it, if you do not, then I wouldn't expect it to really give you an all areas pass to a job. I do see more recently, employers asking for people with certifications as "highly regarded". Listed as mandatory though, are a whole bunch of other skills and experience that you must have, so that gives you some idea.
Then there are those people who get hold of answers to questions, and cheat the certifications, personally, I think that those people do denigrate the certifications, but as mentioned above, someone passing may get them through the door of the interview, but when asked questions, or asked to do something practically, those people are going to have a rather public fall.
One interesting thing that also happened. Whilst studying for the exam, the practice exam software crashed, it seemed, in the C# certification area, so I switched the language to VB.NET and started the exams again. What happened then was that I wasn't really all that aware that I had changed languages, as the knowledge required was more often than not, the same. I also tried that theory out with a C++.NET exam simulation from the CD, and found the same to be true again. That did impress me, and lead me to the question that really a lot of the exams are language agnostic, and the certification is more with the framework than with the language.
I hope this little article is of interest to you, and that you will leave me a couple of comments, as to what you think, and if you agree, or it helps to spur you on to doing the certifications.
Good luck!
Posted by
Martin Platt
at
4:24 PM
2
comments
Labels: .NET, C#, C++, Certification, exam, MCPD, MCTS, MSDC, Qualification, VB