Each week in my Tuesday Lunch & Learn livestream, we look at a useful technical skill, define a challenge related to that skill, and solve the challenge live. This week, it’s testing without mocks.
Although mocks (and spies) are useful for testing interactions and isolating code, that isolation comes at a cost. Mocks can only check if dependencies’ methods are being called. They can’t check if they’re being called correctly. As a result, mock-based tests must be supplemented with integration tests, and these tests are slow and expensive. Wouldn’t it be nice if we could write unit tests that didn’t need additional integration testing?
Our challenge this week: given a simple command-line application, update the existing mock-based tests so they work without mocks, spies, or integration tests. The end result is surprisingly effective: tests that are more reliable than mock-based tests, easier to read, and run 300x faster.
To follow along, download the code from https://github.com/jamesshore/livestream and check out the 2020-05-26 tag. To see the final result, check out the 2020-05-26-end tag or view it on GitHub at https://github.com/jamesshore/livestr....
Auf dieser Seite können Sie das Online-Video Testing Without Mocks mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer James Shore 27 Mai 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 7,072 Mal angesehen und es wurde von 163 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!