Skip to content

Instantly share code, notes, and snippets.

@lucaswkuipers
Last active January 8, 2024 19:42
Show Gist options
  • Save lucaswkuipers/dbdaff2ddce06e05c3452bb9a94a07f9 to your computer and use it in GitHub Desktop.
Save lucaswkuipers/dbdaff2ddce06e05c3452bb9a94a07f9 to your computer and use it in GitHub Desktop.
XCTestCase+trackForMemoryLeak
import XCTest
extension XCTestCase {
func assertDeallocated(
_ instance: AnyObject,
file: StaticString = #filePath,
line: UInt = #line
) {
addTeardownBlock { [weak instance] in
XCTAssertNil(
instance,
"Instance not 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