Personally, I am firmly in the camp of "blackbox testing only". In my opinion, testing the implementation details of software can often lead to false positives, making tests more brittle and harder to understand. This is also why I believe that mocking should generally be avoided.
Instead, when testing a call chain such as a>b>c>d>e, I prefer to test each component-composition in steps, starting with e, then testing d>e, c>d>e, b>c>d>e, and finally a>b>c>d>e. This ensures that the tests better reflect how the software will actually run in production.
I do recognize that mocking can be useful in certain situations, such as when faking external systems, but in general, I believe that it tends to add unnecessary complexity and more importantly increase the likelihood of missed bugs because you're making assumptions about the code you call instead of, well, just calling it.
Writing tests requires time. So, we should not overinvest in them.
What do you think? Do you agree with my approach to testing, or do you see benefits to whitebox testing and mocking?
submitted by /u/TheAuthorBTLG_
[link] [comments]
from Software Development – methodologies, techniques, and tools. Covering Agile, RUP, Waterfall + more! https://ift.tt/ZnfpPQT