我可以多次运行 XCTest 套件吗? [英] Can I run an XCTest suite multiple times?

查看:13
本文介绍了我可以多次运行 XCTest 套件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让 Xcode 多次运行您的单元测试?

Is it possible to have Xcode run your unit tests multiple times?

我在几个单元测试中遇到了导致间歇性故障的问题.现在我认为我已经修复了它,我唯一的选择似乎是混合 + 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.

我知道其他单元测试框架可以很容易地多次运行单个测试、测试用例或测试套件.我们在 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")        
    }
}

这会多次运行 self.measureBlock() 中的代码来测量平均时间.

This runs the code inside self.measureBlock() multiple times to measure the average time.

更改代码是可行的,但您可能还是想知道执行时间.

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.

这篇关于我可以多次运行 XCTest 套件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆