我有以下测试代码:
var returnValue: String?
XCTAssertThrowsError(returnValue = try CommandExecutor.ExecuteXCRun(launchPath: "", arguments: [])) { (error) -> Void in
XCTAssertTrue(error is CommandExecutionError)
}
CommandExecutor.ExecuteXCRun
定义为:
public static func ExecuteXCRun(launchPath: String, arguments: [String]) throws -> String?
该方法在测试期间会按预期抛出错误,但测试失败并且奇怪地甚至注意到该方法引发错误:
错误: - [SwiftXcodeToolsTests.CommandExecutorTests testEmptyArgumentsThrows]:XCTAssertThrowsError失败:抛出 启动路径无法访问 - 测试用例 “ - [SwiftXcodeToolsTests.CommandExecutorTests testEmptyArgumentsThrows]'失败(0.203秒)。
我做错了什么?