Skip to content

Instantly share code, notes, and snippets.

@mitchellporter
Created November 15, 2024 17:39
Show Gist options
  • Save mitchellporter/9b72722d3c8097f1ef66ad7fcbcee3eb to your computer and use it in GitHub Desktop.
Save mitchellporter/9b72722d3c8097f1ef66ad7fcbcee3eb to your computer and use it in GitHub Desktop.
extension XCTestCase {
func trackForMemoryLeaks(_ instance: AnyObject, file: StaticString = #filePath, line: UInt = #line) {
addTeardownBlock { [weak instance] in
XCTAssertNil(instance, "Instance should have been deallocated. Potential memory leak.", file: file, line: line)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment