3 ms·
It's all tradeoffs. Glue code should really only be tested in your integration or E2E tests, you have those, don't you? Now, if A would look like below, we mi
by pintxo 5y ago
It's all tradeoffs.
Glue code should really only be tested in your integration or E2E tests, you have those, don't you?
Now, if A would look like below, we might accept not testing it at all, as the initial and upkeep costs to mock B might be higher then the potential cost of the one-time failure in the internal logic of A.
function A(args) {
return B(args) > 1 ? true : false
}
But, if A looks more like:
function A(args) {
const result = B(args);
switch (result) {
case 1:
case 3: return result * .5;
case 2: return result * result / 5;
}
}
I would probably look to convert it to
function A(args) {
return A1(B(args));
}
enabling me to unit test A1 without thinking about B (and without the cost associated in mocking it)