Mixed heat graph/gradient colors in code coverage report for covermode =set

Hi Team,

I am executing the test command as below wherein I need to get coverage of code present in a different folder, say A and executing tests from a different folder, say B. B folder has code that actually calls APIs in folder A. Below is list of commands executed:

go test -p 1 -cover -coverprofile=coverage.out -coverpkg 'some/path/to/pckgroot'  ./folder1/file1_test.go ./folder1/file.go
go tool cover -html=coverage.out
gocovmerge ./coverage*.out > ./coveragefiles.merged
go tool cover -html=./coveragefiles.merged

Directory Struct:

rootFolder
|- folderA
   |- file1.go
   |- file2.go
|- folderB
   |- file3.go                // a main method inside this file calls APIs from file1.go and file2.go
   |- file3_test.go           // go test is called with this file to cover code in folderA

I am getting the report coverage as fine, however, the heat map is not proper, I am using default covermode as set, so it should give whether code is covered or not i.e. either green or red color.
But I am getting shades green gradient color, I don’t want that.

Kindly help me understand where am I missing anything in between, is it the command being used wrong? Please assist.

Hi Team,

Another query I have around similar lines as above. The directory structure is the same. The folderA is expected to have code covered and folderB is having all testSuite.
With dep, we had go test command as
go test -p 1 -cover -coverprofile=coverage.out -coverpkg 'projectRoot/vendor/www.github.com/x/y.git/src/rootFolder/folderA' ./folderB/file3_test.go ./folder1/file.go which was working fine.
Post migrating to go mod, the above go test command fails as it won’t find the vendor directory which is obvious as after migration there is no vendor directory created. I am not able to get code coverage with any of below values. It is blank all the time.
I am now getting no coverage with any of below coverpkg combinations:
-coverpkg='./...'
-coverpkg='./.../rootFolder/folderA'
-coverpkg='./rootFolder/folderA'

Can someone kindly help in getting proper coverage of package under test?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.