英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论