Chapter 22Fixture Teardown Patterns

Patterns in This Chapter

Teardown Strategy

      Garbage-Collected Teardown 500

      Automated Teardown 503

Code Organization

      In-line Teardown 509

      Implicit Teardown 516

Garbage-Collected Teardown

How do we tear down the Test Fixture?

We let the garbage collection mechanism provided by the programming language clean up after our test.

image

A large part of making tests repeatable and robust is ensuring that the test fixture is torn down after each test and a new one created for the next test run. This strategy is known as a Fresh Fixture (page 311). In languages that provide garbage collection, much of ...

Get xUnit Test Patterns: Refactoring Test Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.