Skip to content

Commit 204d210

Browse files
committed
Improved test robustness for multiple executions
1 parent 5d75507 commit 204d210

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Tests/InterposeKitTests/UtilitiesTests.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ extension NSObject {
2020

2121
final class UtilitiesTests: XCTestCase {
2222

23-
func test_setPerceivedClass() {
23+
static var hasRunTestSetPerceivedClass = false
24+
25+
func test_setPerceivedClass() throws {
26+
// Runs only once to avoid leaking class swizzling across test runs.
27+
try XCTSkipIf(Self.hasRunTestSetPerceivedClass, "Class override already applied.")
28+
Self.hasRunTestSetPerceivedClass = true
29+
2430
let object = RealClass()
2531

2632
XCTAssertTrue(object.objcClass === RealClass.self)

0 commit comments

Comments
 (0)