The Importance of Setup and Teardown
Learn how to use shared code in tests.
When we run xUnit tests, each scenario is isolated from other scenarios, and the tests are typically stateless. However, sometimes different test scenarios have the same setup sequence. Likewise, sometimes test scenarios create artifacts that need to be cleaned up after every run or use unmanaged resources that have to be disposed of correctly. These aspects entail the setup and teardown logic.
The following playground demonstrates examples of the setup and teardown logic in xUnit:
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy