The Hermetic test pattern
The Hermetic test pattern is the polar opposite of the Spaghetti pattern; it states that each test should be completely independent and self-sufficient. Any dependency on other tests or third-party services that cannot be controlled should be avoided at all costs. It is impossible to get a perfectly hermetically sealed test; however, anytime a dependency on anything outside the test is detected, it should be removed as soon as possible.
Note
The Hermetic test pattern can also be referred to as Test is an Island Pattern, which is a play on the word from an old saying no man is an island.
Advantages of the Hermetic test pattern
The Hermetic pattern is especially appealing when trying to flush out test instability. Here are some advantages to hermetically seal your tests:
- Clean start: Each test has a cleaned up environment to work in. This prevents accidental test pollution from previous tests, such as a created user that should not be present.
- Resilience: Each test is...