我在Xcode 7上创建了一个生成代码覆盖数据的项目。
在其DerivedData文件夹中,我可以运行llvm-cov show
/usr/local/opt/llvm/bin/llvm-cov show -instr-profile Build/Intermediates/CodeCoverage/testetestes/Coverage.profdata Build/Intermediates/CodeCoverage/testetestes/Products/Debug-iphonesimulator/testetestes.framework/testetestes这将产生这样的输出:
/Users/marcelofabri/Desktop/testetestes/testetestes/Example.swift:
| 1|//
| 2|// Example.swift
| 3|// testetestes
| 4|//
| 5|// Created by Marcelo Fabri on 09/06/15.
| 6|// Copyright © 2015 Marcelo Fabri. All rights reserved.
| 7|//
| 8|
| 9|import UIKit
| 10|
| 11|class Example: NSObject {
1| 12| func testando() {
1| 13| if let url = NSURL(string: "dasdas") {
1| 14| print("ae \(url)")
0| 15| } else {
0| 16| print("oi")
0| 17| }
1| 18| }
| 19|}
/Users/marcelofabri/Desktop/testetestes/testetestes/OutraClasse.swift:
| 1|//
| 2|// OutraClasse.swift
| 3|// testetestes
| 4|//
| 5|// Created by Marcelo Fabri on 18/06/15.
| 6|// Copyright © 2015 Marcelo Fabri. All rights reserved.
| 7|//
| 8|
| 9|import UIKit
| 10|
| 11|class OutraClasse: NSObject {
| 12|
1| 13| func outroTestando() {
1| 14| if let numero = Int("123") {
1| 15| print("ae \(numero)")
0| 16| } else {
0| 17| print("oi")
0| 18| }
1| 19| }
| 20|
| 21|}但是,我希望获得.gcov文件,因为这是大多数工具所使用的。有没有一种不解析输出和手动创建.gcov文件的方法来做到这一点?
发布于 2015-07-02 05:33:36
根据Apple的说法,gcov并不是Xcode 7覆盖支持的一部分。戈夫是gcc留下的遗产,一直呆到被替换的时候。显然,他们放弃了遗留的gcov文件格式支持,转而支持新的中间格式- profdata。我自己做了研究,没有找到任何工具将profdata转换回gcov,但是有Slather from Venom。Slather能够用Gutter JSON、Cobertura、HTML和普通测试生成覆盖报告。它还可以提供与流行的服务,如工作服的集成。目前,它也只适用于gcov,但是它们已经打开了问题,而PR请求也在等待对profdata的支持。他们通常动作很快,所以很快就会被并入大师。
此外,如果您决定编写自己的工具,您可能会考虑多种方法来审查:
https://stackoverflow.com/questions/31040594
复制相似问题