简体   繁体   English

单元测试的Xcode 9代码覆盖率显示错误百分比

[英]Xcode 9 code coverage on unit tests showing wrong %

The Code Coverage report generated by XCode 9 seems to be off on some files in my project. XCode 9生成的代码覆盖率报告似乎关闭了我的项目中的某些文件。 It shows 0% in one of the class file 它在一个类文件中显示0% 在此输入图像描述 While when I check the codes it actually covered by the test 当我检查测试实际覆盖的代码时 在此输入图像描述

It looks like that the coverage report is actually in-sync with the tests??? 看起来覆盖率报告实际上与测试同步???

Environment: Xcode 9.2 Swift 4 环境:Xcode 9.2 Swift 4

I believe you'll find the answer here Code coverage result is not accurate to real coverage in Xcode 7 我相信你会在这里找到答案代码覆盖率结果不准确到Xcode 7中的真实覆盖范围

Briefly it says to use 简单地说它要使用

@testable import <yourapp>

In each test file and don't add your app .swift files to the test targets. 在每个测试文件中,不要将您的应用.swift文件添加到测试目标。

Works for me. 适合我。

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

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