unit-testinggotestingcucumbergo-testing

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 :)


Solution

  • 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