3 ms·
The integration tests that you are describing behave much like I would expect unit tests to behave. Give an input, assert the results (return value or state cha
by wakamoleguy 8y ago
The integration tests that you are describing behave much like I would expect unit tests to behave. Give an input, assert the results (return value or state change). The example of optimizations breaking the unit test could be either a poor test (If the function doesn't need to call that intermediate with that data, why is it being tested?). Oftentimes the spy is added to the test because there is unnecessary tight coupling between two units.
This isn't to say that integration tests aren't great, too. They all tell different stories. I like unit tests, as they force me to think about modules as units. If a unit is hard to test or brittle, it may need more attention to its design.
- stevesmithwick 8y agoA good use of mocks/spies is if you need to test a side-effect. For instance: did your code call that service with the right parameters?