go test的不同测试标志之间的区别是什么?

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

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的新手表示抱歉 go test的不同测试标志之间的区别是什么?

英文:

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 go test的不同测试标志之间的区别是什么?

答案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

huangapple
  • 本文由 发表于 2022年7月1日 16:10:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/72826249.html
匿名

发表评论

匿名网友

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

确定