Summary
In this chapter, we discussed the harmful effects of code duplication on the test suite. As the application keeps evolving, the time required to keep the tests up to date grows exponentially. The solution for this is to avoid code and test duplication by using the DRY testing pattern. We applied the DRY principle by refactoring duplicate code into the setup and teardown methods and other methods that our tests can share.
We also removed the interdependency between our two tests by using the Hermetic test pattern. Removing the Spaghetti pattern from our suite has dramatically increased the test stability. Random order ability was achieved by hermetically sealing our tests and having them use unique data.
In the next chapter, we will be concentrating ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access