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 on test data and how to manage it in different environments.