UI Test Case not show code coverage

纵然是瞬间 提交于 2019-11-30 04:31:41
alexem

Check if the "Gather coverage data" is active in the Test Scheme.

This happens if you have only UI test target. Add a Unit Test Target. And then run tests again. This time you will see the code coverage.

UITestcase does not provide coverage data without Unit testing code. You could try this. Have a button in your Viewcontroller, attach an IBAction to it. And create UITestcase to it. Check the code coverage with and without UITestcases. You would see the difference. The difference would give you the code coverage by the UITestcase. As of now, Xcode doesnt provide, code coverage data seperately. It is dependant on the Unit Testcases.

Test coverage without UI TestCase

---With your code I have commented out your

func testStepper() {

    let steppersQuery = app.steppers
    steppersQuery.buttons["Increment"].tap()
    steppersQuery.buttons["Decrement"].tap()
}

func testSegmented() {
    app.buttons["Second"].tap()
    app.buttons["Fourth"].tap()
    app.buttons["Third"].tap()
    app.buttons["First"].tap()

}

from TestDemoUITests and the result was this

And with your UITestcase it is as follows

It is pretty much evident now that UITestcase adds to the Unit Testcase for code coverage.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!