DEV Community

Discussion on: what is an example of too much test cases?

Collapse
 
nflamel profile image
Fran C.

There's a very good talk from Sandi Metz which explains how to decide when is enough (regarding unit tests) youtube.com/watch?v=URSWYvyc42M

As for integration/E2E/whatever tests what I do is to take into account that tests have a cost and that I want to get the biggest benefit from them with the smaller cost possible.

If I can avoid adding a test, I do. Unless of course adding the test saves me money/time/whatever other costs.

In this case, my questions would be:

  • Do you need to have tests for KlassB and KlassC at all?
  • Are they only collaborators of KlassA or are they widely used around your app? Then test only KlassA unless you can find another very good reason to test B and C.
  • Is KlassA only delegating into those? Then I wouldn't test KlassA except for some integration.
  • Is KlassA doing some other query or does it have any other side effect? Then I would definitely test those as well.