Exclude Files/Lines of code in Xcode 7 Code Coverage

ⅰ亾dé卋堺 提交于 2020-01-10 08:39:15

问题


How would you exclude a few methods, or say the AppDelegate file, from being tested during Code Coverage in Xcode 7?

I am not using Gcov.


回答1:


Xcode coverage is generated by target (you can enabled it per scheme). Something I often do is separate all my testable code into a separate DynamicFramework from all my UI code. I can generate coverage just for that one framework if i like.

Alternatively you could look at some of the 3rd party coverage parsing tools such as:

  • xcov
  • slather

Each tool will generate you a set of coverage metrics (based on the coverage data generated by Xcode) and they have the ability to exclude specific files from the coverage generation.

Xcov

--ignore_file_path -x: Relative or absolute path to the file containing the list of ignored files.

Slather

# .slather.yml
ignore:
 - ExamplePodCode/*
 - ProjectTestsGroup/*

Personally I find that xcov is nicer to look at but slather is slightly more detailed



来源:https://stackoverflow.com/questions/33887690/exclude-files-lines-of-code-in-xcode-7-code-coverage

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