Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"notest" comment does not work in my setup #31

Open
lixvbnet opened this issue Oct 24, 2022 · 1 comment
Open

"notest" comment does not work in my setup #31

lixvbnet opened this issue Oct 24, 2022 · 1 comment

Comments

@lixvbnet
Copy link

lixvbnet commented Oct 24, 2022

Hi, it's great to find this tool.
But after trying for hours, I'm still having trouble to have it work.

pac.go: (you can see I have tried adding "notest" everywhere..

package newpac

import "fmt"

func max(a, b int) int {
	if a > b {
		// notest
		fmt.Println("gt") // notest
		return a          // notest
	} else {
		fmt.Println("lt")
		return b
	}
}

pac_test.go

package newpac

import (
	"fmt"
	"testing"
)

func Test1(t *testing.T) {
	res := max(3, 5)
	fmt.Println(res)
}

Run command:

go install github.com/dave/courtney@latest
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install github.com/matm/gocov-html@latest

courtney -v -o c.out && gocov convert c.out | gocov-html > C.html 

But still getting same report as before,
image

My Go version is 1.17, and I have downgraded to 1.16 but still got same result. Am I missing anything?

@lixvbnet
Copy link
Author

I did further testing. This might have to do with the way gocov convert handles the c.out file.

(1) Run go test -v -coverprofile=c.out
c.out

mode: set
tttmod/newpac/pac.go:5.24,6.11 1 1
tttmod/newpac/pac.go:6.11,10.3 2 0
tttmod/newpac/pac.go:10.8,13.3 2 1

(2) Run courtney -v -o c.out
c.out

mode: set
tttmod/newpac/pac.go:5.24,6.11 1 1
tttmod/newpac/pac.go:10.8,13.3 2 1

For both (1) and (2), gocov convert c.out | gocov-html > C.html would produce same report (60% coverage)

But if add the excluded lines to c.out and set last bit to 1, then coverage score becomes 100%.

mode: set
tttmod/newpac/pac.go:5.24,6.11 1 1
tttmod/newpac/pac.go:6.11,10.3 2 1
tttmod/newpac/pac.go:10.8,13.3 2 1

I have an existing setup which uses gocov-xml to integrate with Jenkins, and gocov-html for handy coverage report, but with no way to exclude code blocks for coverage report. So I really wish to have courtney and gocov tools work together!

Then my issue becomes: Is there any way or workaround to have courtney include the missing lines in the output file, with last bit set to 1 ? Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant