<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTest/tearDown()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTest(im)tearDown"
  },
  "title" : "tearDown()"
}
-->

# tearDown()

Provides an opportunity to perform cleanup after each test method in a test case ends.

```
func tearDown()
```

## Discussion

After each test completes, `XCTest` calls [`tearDown()`](/documentation/XCTest/XCTest/tearDown()), then `tearDownWithError()`, followed by [`tearDown(completion:)`](/documentation/XCTest/XCTest/tearDown(completion:)). Override this method to perform any per-test cleanup.

If state cleanup might throw errors, override [`tearDownWithError()`](/documentation/XCTest/XCTest/tearDownWithError()) or [`tearDown(completion:)`](/documentation/XCTest/XCTest/tearDown(completion:)) instead. `XCTest` marks the test failed when when it catches errors, or skipped when it catches `XCTSkip`.

## See Also

[`class func tearDown()`](/documentation/XCTest/XCTestCase/tearDown())

Provides an opportunity to perform cleanup after a test case ends.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)