Wednesday, April 6, 2016

Unit Testing: When You're not really Testing Your Logic

However if I am working on a PR for the winrm ruby gem that implements the winrm protocol or I am working on provisioning a VM or am leaning heavily on something that uses the windows registry, if I mock away all of these layers, I may fall into the trap where I am not really testing my logic.
If I mock everything out I may just end up testing that I am calling the correct API endpoints with the expected parameters. This can be useful to some extent but can quickly start to smell like the tests just repeat the implementation. 
Unit tests play the part of the compiler for interpreted languages:
If anything, unit tests that do no more than merely walk all possible code paths can protect code from randomly blowing up. 
http://www.hurryupandwait.io/blog/why-tdd-for-powershell-or-why-pester-or-why-unit-test-scripting-language

No comments:

Post a Comment