I think verifying non-state-changing methods is still valuable when doing TDD as they form a low-level specification of the system-under-test. However, I think a better strategy would be separating tests that verify state-changing and non-state changing methods. That way you get the best of both worlds.
"it would be even better to use a real or fake object to actually execute the method and check that it works properly"
I strongly disagree. This would mean that not only the code under test is tested but also the called code, which should have its own unit tests. The harm it does is the following: If the called code fails, not only its tests fail, but also all tests that call it. It makes your tests more brittle and also makes it harder to find quickly what actually went wrong.
I would guess it's an integration test since the intention is to test multiple calls in one test. It should be known that the code has issues while doing the unit tests (like addPermissionTest) before the integration test.
I think verifying non-state-changing methods is still valuable when doing TDD as they form a low-level specification of the system-under-test.
ReplyDeleteHowever, I think a better strategy would be separating tests that verify state-changing and non-state changing methods. That way you get the best of both worlds.
"it would be even better to use a real or fake object to actually execute the method and check that it works properly"
ReplyDeleteI strongly disagree. This would mean that not only the code under test is tested but also the called code, which should have its own unit tests. The harm it does is the following: If the called code fails, not only its tests fail, but also all tests that call it. It makes your tests more brittle and also makes it harder to find quickly what actually went wrong.
newbie here.
DeleteI would guess it's an integration test since the intention is to test multiple calls in one test.
It should be known that the code has issues while doing the unit tests (like addPermissionTest) before the integration test.