Skip to main content
added 34 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

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?

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection 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?

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?

deleted 144 characters in body
Source Link
Bryan Oakley
  • 25.4k
  • 5
  • 66
  • 89

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection 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?

Put another way, you aren't testing that the functions it calls work, you're testing that it calls the correct functions in the proper manner.

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection 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?

Put another way, you aren't testing that the functions it calls work, you're testing that it calls the correct functions in the proper manner.

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection 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?

added 21 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection 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?

Put another way, you aren't testing that the functions it calls work, you're testing that it calls the correct functions in the proper manner.

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection 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?

Put another way, you aren't testing that the functions it calls work, you're testing that it calls the correct functions.

Should savePeople() be unit tested? Yes. You aren't testing that dataStore.savePerson works, or that the db connection 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?

Put another way, you aren't testing that the functions it calls work, you're testing that it calls the correct functions in the proper manner.

added 45 characters in body
Source Link
Bryan Oakley
  • 25.4k
  • 5
  • 66
  • 89
Loading
Source Link
Bryan Oakley
  • 25.4k
  • 5
  • 66
  • 89
Loading