【发布时间】:2016-08-08 03:32:54
【问题描述】:
是否可以在正在运行的测试中检查其 XCTAsserts 是否失败?我有一个连续几个断言的测试,如果其中任何一个失败,我想在之后添加一些代码来执行特定操作:
class testClass : XCTestCase
{
func testSomething()
{
let someComputedValue1 = func1()
let someComputedValue2 = func2()
XCTAssertLessThanOrEqual(someComputedValue1, 0.5)
XCTAssertLessThanOrEqual(someComputedValue2, 0.2)
if anyOfTheAboveAssertionsFailed {
performAction()
}
}
}
我想要提示的部分是 anyOfTheAboveAssertionsFailed 条件,而无需重复与硬编码值的比较。
【问题讨论】:
标签: swift xctest xctestcase