简体   繁体   English

Xcode测试用例显示没有测试覆盖率

[英]Xcode test cases shows no test coverage

I'm having problem with getting code coverage in Xcode. 我在Xcode中获取代码覆盖率时遇到问题。 It was working at some point of time, however after sometime it has just stopped showing coverage. 它在某个时间点工作,但是在一段时间后它刚刚停止显示覆盖范围。 I've checked both the schemes and test coverage plane for the appropriate settings. 我已经检查了方案和测试覆盖平面以获得适当的设置。

This is how my scheme looks like: 这是我的计划的样子: 在此输入图像描述

This is what my test coverage plane shows after running test cases: 这是我的测试覆盖平面在运行测试用例后显示的内容: 在此输入图像描述

I tried many many things to get this fixed. 我尝试了很多东西来解决这个问题。 Finally I ended up deleting all Xcode I had in the Mac, and cleared all the meta-data from /Users/bbirani/Library/Developer/ . 最后,我最终删除了Mac中的所有Xcode,并清除了/Users/bbirani/Library/Developer/所有元数据。 After all this clean-up, I re-installed Xcode and VOILAA!! 在完成所有这些清理之后,我重新安装了Xcode和VOILAA !! it started working. 它开始工作了。

It happens to me a lot. 它发生在我身上很多。 Try restarting your xcode as well as the simulator(if you are using one). 尝试重新启动您的xcode以及模拟器(如果您使用的是)。 It seems like an xcode issue. 这似乎是一个xcode问题。

You can try some of this 你可以试试其中一些

  1. Enabling the "show code coverage" from Editor while running a test case. 在运行测试用例时从编辑器启用“显示代码覆盖率”。 I had this same problem before worked for me. 在为我工作之前我遇到过同样的问题。 Just try and see if that is working. 试试看是否有效。
  2. You can try checking the targets for the modules but not sure thats the case. 您可以尝试检查模块的目标,但不确定是这种情况。
  3. Or you can use the @testable way.This is a workaround and the long way to solve this. 或者你可以使用@testable方式。这是一种解决方法,也是解决这个问题的好方法。
  4. Also u can try cleaning the whole project and deleting any derived data.And then try running the test case. 您也可以尝试清理整个项目并删除任何派生数据。然后尝试运行测试用例。
  5. Also you can try deleting the scheme and try making a new scheme and check "Gather coverage data" for the same. 您也可以尝试删除该方案并尝试制定新方案并选中“收集覆盖数据”。 If this things work then thats a xcode bug. 如果这件事有效,那就是一个xcode错误。

I hope your problem gets solved, I got stuck to the same problem before and it was frustrating to solve that, and you never know which way might work. 我希望你的问题得到解决,我之前遇到了同样的问题,解决这个问题令人沮丧,你永远不知道哪种方式可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM