Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between differents test-flags of 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 :)

like image 776
Pulkit Gupta Avatar asked Oct 18 '25 17:10

Pulkit Gupta


1 Answers

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
like image 143
h0ch5tr4355 Avatar answered Oct 20 '25 12:10

h0ch5tr4355