“covered” 和 “not tracked” 在 Go 测试覆盖率中的含义是什么?

huangapple go评论69阅读模式
英文:

What is the meaning of covered and not tracked in Go test coverage?

问题

我已经开始了一个小的Go应用程序来进行测试和学习。在主包中,我有一个名为main.go的文件,其中包含一个名为NewApp的函数。

在我的测试文件中,我多次调用了它,但在覆盖率报告中,它的第一行被标记为“未跟踪”。这个函数返回一个App struct,但整个结构的定义也被标记为“未跟踪”。

另一方面,我不明白“未覆盖”和“未跟踪”的区别。是否有一种方法可以测试主函数?我看不出这样做的优势。

我的代码在这里

英文:

I've started a small Go application to test it out and learn. In the main package I have a main.go with for example a function called NewApp.

In my test file I've called it several times, but in the coverage report its first line is marked as "not tracked". This function returns an App struct, but the whole struct definition is marked as "not tracked" to.

On the other hand I can't understand the difference between "not covered" and "not tracked". And is there a way to test the main function? I can't see the advantage of that.

My code is here.

答案1

得分: 1

谢谢,所以“未跟踪”不会计入覆盖率百分比中。

英文:

Thanks, so "not tracked" it is not considered in the coverage percentage.

huangapple
  • 本文由 发表于 2016年9月28日 04:12:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/39733494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定