Xcode中的代码覆盖率,无需测试(用于手动运行) [英] Code coverage in Xcode without tests (for manual run)
问题描述
代码覆盖率通常用于Xcode中的测试.我想将其用于手动执行的应用程序.我可以使用第三方工具来做到这一点吗?
Code Coverage is commonly used with tests in Xcode. I would like to use it for manually executed app. Can I do it, possibly with third-party tools?
例如:我在设备上构建并启动该应用,使用它执行一些操作,然后查看代码覆盖率结果.
For example: I build and launch the app on device, perform some actions with it and then look at code coverage results.
推荐答案
The solution was suggested by someone here: https://github.com/SlatherOrg/slather/issues/209
您可以尝试让XCUITest永久休眠,然后手动使用该应用程序,并查看终止时是否生成覆盖文件.
我只是尝试了该解决方案,它对我来说非常合适:
I simply tried the solution and it worked perfectly for me:
class FooTests: XCTestCase {
override func setUp() {
super.setUp()
let app = XCUIApplication()
app.launch()
}
func testBalances() {
sleep(30)
XCTAssert(true)
}
}
在 XCTAssert(true)
上测试成功后,我可以看到手动用例的代码覆盖率.您可以玩 sleep(30)
来满足您的需求.
After the test succeeded on XCTAssert(true)
, I could see the code coverage for the manual use cases. You can play around with the sleep(30)
to match your requirement.
这篇关于Xcode中的代码覆盖率,无需测试(用于手动运行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!