Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI Test Case not show code coverage

I have some tests written using XCTestCase classes and I want to calculate code coverage. For the regular test it is shown nicely in my bot, but for UI Tests is always 0%.

The simplest test:

import XCTest  class FAQUITests: XCTestCase {      let app = XCUIApplication()             override func setUp() {         super.setUp()         app.launch()     }      func openFaqView() {         app.navigationBars["NavigationBar"].buttons["FAQ"].tap()     }      func testFaq() {         openFaqView()         app.tables.cells.elementBoundByIndex(0).tap()     }          } 

And this surely should show some test coverage but it's not. I set in my bot code coverage enabled:

enter image description here

And result:

enter image description here

Still 0%.

Xcode 7.2 (7C68)

EDIT: Example Project : https://[email protected]/Kettu/so_34718699.git

like image 665
Jakub Avatar asked Jan 11 '16 10:01

Jakub


People also ask

How do I display code coverage?

On the Test menu, select Analyze Code Coverage for All Tests. You can also run code coverage from the Test Explorer tool window. Show Code Coverage Coloring in the Code Coverage Results window. By default, code that is covered by tests is highlighted in light blue.

How is UI test coverage measured?

Calculating test coverage is actually fairly easy. You can simply take the number of lines that are covered by a test (any kind of test, across your whole testing strategy) and divide by the total number of lines in your application.

How do I show test coverage in Xcode?

To view the coverage reports: Select the Report Navigator in the navigator pane on the left (⌘8) Select the latest Test run in the navigator pane. Select the Coverage tab in the editor.


1 Answers

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

Check Gather coverage data

like image 97
alexem Avatar answered Oct 04 '22 05:10

alexem