UI Test Case not show code coverage UI Test Case not show code coverage xcode xcode

UI Test Case not show code coverage


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

Check Gather coverage data


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.Sample Targets

enter image description here

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 TestCasewith UI Testcase

---With your codeI 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 thiswithout UITesting code

And with your UITestcase it is as followswith UITestcase

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