Skip to content

Commit

Permalink
Simplify suppressable test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jmp committed Oct 30, 2021
1 parent 2bc6be7 commit 88f96bc
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions Tests/AssertThatTests/Helpers/SuppressableTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,24 @@ import XCTest

class SuppressableTestCase: XCTestCase {
private(set) var suppressedIssues = 0
private var isSuppressing = false

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
override func record(_ issue: XCTIssue) {
if isSuppressing {
suppressedIssues += 1
} else {
super.record(issue)
}
suppressedIssues += 1
}
#else
#else
override func recordFailure(
withDescription description: String,
inFile filePath: String,
atLine lineNumber: Int,
expected: Bool
) {
if isSuppressing {
suppressedIssues += 1
} else {
super.recordFailure(withDescription: description, inFile: filePath, atLine: lineNumber, expected: expected)
}
suppressedIssues += 1
}
#endif
#endif

func suppress(_ block: () -> Void) {
suppressedIssues = 0
isSuppressing = true
defer { isSuppressing = false }
block()
}
}

0 comments on commit 88f96bc

Please sign in to comment.