A common misconception is that a failed test or code should be debugged. On the contrary, if the test implementation is fast enough a better and easier way is to remake of the failed steps.
Most IT people know Kernighan's Law – “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” It’s true, I know very good developers who have serious problems with debugging. Debugging is not only difficult, but it’s an activity nobody likes. At least I never heard anybody who liked debugging.
Maybe debugging the failed tests is easier than debugging a complicated code, but it’s not easy and takes some time. Unfortunately, most developers and testers believe that the only way to fix bad code or a bad test is to debug it, and when the fault has been detected, then fix it. However, this is not true. We don’t need to know what the problem is, we only need to fix the code to work properly or the test case to pass.
The question is how to fix a test case that failed or a bug in the code without knowing the problem. The answer is easy: make it again from scratch. Obviously, this method cannot be generally used. If a code is difficult to make, then debugging can be faster. However, the faster a test case can be implemented the higher the chance that the reimplementation is faster than debugging and fixing together.
When applying two-phase model-based testing, the test implementation is four to five times faster than coding the same test cases. On the other hand, the debugging of a failed test takes almost the same time as in the case of coding. The consequence is that if you use a fast test automation method, then don’t debug, but make the failed steps again. That’s why I almost never debug a test case.
This method also works when a requirement has been modified. If the modified code works well, the outdated test case fails. Don’t try to repair it, you had better do it again.
Here is an example of applying our Harmony tool.
The first step is to delete the implementation at a failed step:
After clicking on the current total price 9, the test passes:
The whole process took less than half a minute. Our advice is to use a tool by which you can completely avoid the tiresome and difficult debugging.
Comments