Is code coverage already working for Swift?

亡梦爱人 提交于 2019-12-04 15:37:23

问题


I am trying to setup test code coverage for a Swift application on Xcode 6 Beta 4.
I was able to do so in the past using ObjectiveC with Xcode 5, however I think I had to call the void __gcov_flush() method, to trigger generation of the .gcda/.gcno files.
I set both properties for instrumentation and code coverage to YES for the app and test targets.
However after running the tests, when I look in:
DerivedData/some subfolders/i386 all I see are files of type:
.d,.dia,.o,.swiftmodule and so on, but nothing that indicates code coverage.

Therefore I have two questions:

  1. Is code coverage expected to work for Swift using Xcode6 beta 4?
  2. If yes and it is necessary to flush gcov first, how do I do that from Swift?

Thanks


回答1:


Xcode 6 Beta 4 does not have code coverage for Swift working. There is an open Apple issue with id: 17450338 against it.




回答2:


Code coverage for Swift is available in Xcode 7. You can turn it on in the test settings for your scheme, by ticking the checkbox labeled "Gather coverage data."

Note that Apple has introduced a new format for the coverage data, profdata files.

Links:

  • Xcode Overview: Using Code Coverage (Mac) (Apple docs)
  • Xcode Overview: Using Code Coverage (iOS) (Apple docs)
  • Leveraging Swift Code Coverage with Xcode 7 (blog post, not mine)



回答3:


It does not fixed in Xcode 6.3, see http://openradar.appspot.com/radar?id=6457429508227072



来源:https://stackoverflow.com/questions/25006983/is-code-coverage-already-working-for-swift

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