Xcode 7.3.1 UITests Code Coverage always at 0%

北慕城南 提交于 2019-12-12 12:35:37

问题


I have two separate targets for Unit Testing and UI Testing in my project besides the main app . These two targets have separate schemes so that i can run them on my CI server separately. I check "Gather Code Coverage" in both of this schemes. Initially i made sure everything is working from XCode by building and running these two schemes separately using "Cmd + U" and coverage data is shown properly for both of these schemes....

In my Jenkins CI i have separate jobs for these two schemes using fastlane, Unit Test scheme is working fine and generating reports. But the UI Test Scheme always shows 0% coverage report no matter what. I don't know what am doing wrong.

Somewhere i read about UI Tests depends on Unit Tests in order for the code coverage, is that true ? If it is true then should i run Unit Tests Before performing UI Tests ?

Thanks in advance.


回答1:


But the UI Test Scheme always shows 0% coverage

UI testing doesn't cover any code. It can't see your code. It has never heard of your code. It knows nothing of your code. It has nothing to do with your code! It merely clicks buttons and reads the interface of your app from the outside. In effect, all it can "see" is the screen.




回答2:


The previews answer is kind of wrong sir. Even the Xcode shows line coverage due UITests, so of course UITest knows your code, of course it call your code to execute your UI. Only problem is that jenkins is having problem with it since an already known Apple's bug. The gather coverage data debug format have report issues.. Just have a look at the bug's report.



来源:https://stackoverflow.com/questions/38334050/xcode-7-3-1-uitests-code-coverage-always-at-0

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