Created
June 15, 2022 10:46
-
-
Save erkekin/0f44eefb62f62e9f79b8f544ca2dd46e to your computer and use it in GitHub Desktop.
Test strong reference cycles within unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func AssertNoStrongReferenceCycle<T: AnyObject>( | |
file: StaticString = #file, | |
line: UInt = #line, | |
act: () throws -> T | |
) rethrows { | |
weak var system: T? | |
try autoreleasepool { | |
system = try act() | |
} | |
XCTAssertNil(system, "You've got a reference cycle in \(T.self).", file: file, line: line) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bkz: https://erkekin.com/swift-unit-test-ile-strong-reference-cycle-yakalama