In addition to possibility of an API that silently relies on global variables there are more potential pitfalls.
Suppose that you have a global variable which is modified within ten different if-else blocks. You wrote two tests - in one all ifs are true, in another all ifs are false. Now you believe that you have 100% code coverage.
The real coverage, however is not so good. 10 ifs that manipulate the same globals are semantically similar to a huge switch-case statement with 2^10=1024 possible cases. It will take 1024 tests to give true full coverage.
No comments:
Post a Comment