問題描述
是否可以讓 Xcode 多次運(yùn)行您的單元測試?
Is it possible to have Xcode run your unit tests multiple times?
我在幾個單元測試中遇到了導(dǎo)致間歇性故障的問題.現(xiàn)在我認(rèn)為我已經(jīng)修復(fù)了它,我唯一的選擇似乎是混合 ? + U 直到我有 95% 的把握該錯誤是走了.
I had an issue in several unit tests that caused intermittent failures. Now that I think I've fixed it, my only option appears to mash ⌘ + U until I'm 95% confident the bug is gone.
我知道其他單元測試框架可以很容易地多次運(yùn)行單個測試、測試用例或測試套件.我們在 XCTest 中是否擁有這種奢侈?
I know other unit testing frameworks make it quite easy to run a single test, test case, or test suite multiple times. Do we have this luxury in XCTest yet?
推薦答案
或許對你使用有幫助
func testMultiple() {
self.measureBlock() {
...
XCTAssert(errMessage == nil, "no error expected")
}
}
這會多次運(yùn)行 self.measureBlock() 中的代碼來測量平均時間.
This runs the code inside self.measureBlock() multiple times to measure the average time.
更改代碼是可行的,但您可能還是想知道執(zhí)行時間.
It is work to change the code, but you might want to know the execution time anyways.
這個答案可能與您想要的足夠接近,并且很容易做到.
This answer might be close enough to what you want and it is easy to do.
這篇關(guān)于我可以多次運(yùn)行 XCTest 套件嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!