Should savePeople()
be unit tested? Yes. You aren't testing that dataStore.savePerson
works, or that the db connection works, or even that the foreach
works. You are testing that savePeople
fulfills the promise it makes through its contract.
Imagine this scenario: someone does a big refactor of the code base, and accidentally removes the forEach
part of the implementation so that it always only saves the first item. Wouldn't you want a unit test to catch that?