Search code examples
iosswiftunit-testingxctesttest-coverage

Why? Class showing in Unit test coverage Even though not added in test targets


I have a few UIView class which is coming under coverage even though. I haven't added them under unit test target. Neither in unit test nor UI unit test. but still those file showing.

I do not know whether they are included in test coverage.

Q: How we can remove them from unit test coverage? Q: Are they involve in unit test coverage score?

Class included in unit test coverage:

enter image description here

Classes not added in test targets:

enter image description here


Solution

  • Hi @Sandy, to answer your questions:

    How we can remove them from unit test coverage?

    As of Xcode 10.2 there is no way to exclude files from the test coverage report.

    Are they involve in unit test coverage score?

    Yes they are. All the files contribute to the total coverage %.

    If you want to compute a test coverage score that doesn't take into account certain files, your best chance is to write a script to parse the xccov output.

    I can't find any official documentation of how to interact with it but this post is a good place to start.