mardi 29 décembre 2020

wait function can't inject file, line, not the same on apple/swift-corelibs-xctest

I was trying to refactor my Unit test file to have some asynchronous API, I was trying to have a custom expectation function as followed.

func expect(_ sut: SUT, toCompleteWith: EQUATABLE, when action: () -> Void, file: StaticString = #file, line: UInt = #line) {
    ...
      wait(for: [exp], timeout: 1.0, enforceOrder: false, file: file, line: line)
}

But it seems like the wait method on XCTestCase did not have the file, line as input. And the Apple Document about wait did not have the file either.

Apple Document about wait: https://developer.apple.com/documentation/xctest/xctestcase/2806856-wait

However, I found on apple/swift-corelibs-xctest do have the file, line API

apple/swift-corelibs-xctest about wait: https://github.com/apple/swift-corelibs-xctest/blob/1764c5432ac5a2d8c4de5373fa19ad43c870cf1e/Sources/XCTest/Public/Asynchronous/XCTestCase%2BAsynchronous.swift#L87

To be honest, I don't what to do right now, but here's my thought on this:

  1. I just give up on this and try to import XCTest from GitHub, but it may fail due to the same framework name(just thinking, did not give it a try).
  2. File a bug report, but I really not comfortable with this.

Aucun commentaire:

Enregistrer un commentaire