kylef / Spectre

BDD Framework and test runner for Swift projects and playgrounds
BSD 2-Clause "Simplified" License
404 stars 41 forks source link

Xcode12 support #40

Closed kenmaz closed 4 years ago

kenmaz commented 4 years ago

XCTestCase.recordFailure(..) method has been deprecated on Xcode12+ and it will cause compile error on Xcode12.

スクリーンショット 2020-07-05 0 41 33

To avoid that, added @available block. In the future, XCTestCase. recordFailure(..) should be replaced with new API, XCTestCase.record(_:).

Video https://developer.apple.com/videos/play/wwdc2020/10687/ Document https://developer.apple.com/documentation/xctest/xctestcase/3546549-record

amine2233 commented 4 years ago

you can use this code instead of just checking if you are on macosx 10.13

if #available(OSX 10.13, *) {
        testCase.recordFailure(withDescription: "\(name): \(failure.reason)", inFile: failure.file, atLine: failure.line, expected: false)
    } else {
        let location = XCTSourceCodeLocation(filePath: failure.file, lineNumber: failure.line)
        let issue = XCTIssue(type: .assertionFailure, compactDescription: "\(name): \(failure.reason)", detailedDescription: nil, sourceCodeContext: .init(location: location), associatedError: nil, attachments: [])
        testCase.record(issue)
    }
amine2233 commented 4 years ago

please it's very important to merge this pr and create a new release, because some project needed to run on Xcode 12 and on macOS Big Sur like XcodeGen

aaronbrethorst commented 4 years ago

Hey @kylef - any word?

kylef commented 4 years ago

These changes would render Spectre test failures as successes with the Xcode reporter in many cases. This change won't be accepted in its current state, this must be fixed before this change can be considered.