英文:
Difference between differents test-flags of go test
问题
我计划在Go中运行我的Cucumber测试(使用Godog),并想出了以下可能的测试命令。有人可以指出这些命令之间的区别吗?哪种方式被推荐使用,每种覆盖模式的用例是什么?
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage.out -race
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage1.out -covermode=set
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage2.out -covermode=atomic
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage3.out
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage4.out
PS:对于GO的新手表示抱歉
英文:
I am planning to run my Cucumber test in go (using Godog) & I came up with the following possibility of commands to run my tests.
Can someone point out the differences here? What is the recommended way & what's the use-case of each cover mode etc?
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage.out -race
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage1.out -covermode=set
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage2.out -covermode=atomic
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage3.out
go test -test.v -test.run ^TestFeatures$ -coverpkg=../... -coverprofile=coverage4.out
PS: Apologies for being a noob in GO
答案1
得分: 3
这在 GO 博客上有解答:https://go.dev/blog/cover#heat-maps:
- set:每个语句是否执行?
- count:每个语句执行了多少次?
- atomic:类似于 count,但在并行程序中精确计数。
英文:
This is answered on the GO blog: https://go.dev/blog/cover#heat-maps:
> - set: did each statement run?
> - count: how many times did each statement run?
> - atomic: like count, but counts precisely in parallel programs
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论