Closed mkuznetsov2 closed 7 months ago
I can't reproduce this behaviour, using go test -v -coverprofile=coverage.txt -covermode count
I get coverage information in coverage.txt.
What does go env
show for you and what version of testify are you using?
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/m.kuznetsov/Library/Caches/go-build'
GOENV='/Users/m.kuznetsov/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/m.kuznetsov/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/m.kuznetsov/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.21.6/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.21.6/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/0b/1yz4ln6s3_9dlxnk8qxyg5d81c7vwk/T/go-build2343961692=/tmp/go-build -gno-record-gcc-switches -fno-common'
But in CI/CD it doesn't work too. I use GitlabCI and image golang:1.21-bookworm
What testify version are you using?
Using (mostly) your code example with go 1.21.6 on darwin/arm64 I get coverage:
% go version
go version go1.21.6 darwin/arm64
% go test -v -coverprofile=coverage.txt -covermode count
=== RUN TestRun
=== RUN TestRun/TestSuite1
--- PASS: TestRun (0.00s)
--- PASS: TestRun/TestSuite1 (0.00s)
PASS
coverage: 100.0% of statements
ok github.com/brackendawson/kata 0.593s
% cat coverage.txt
mode: count
github.com/brackendawson/kata/kata.go:3.21,5.2 1 1
Does your code actually have any statements?
github.com/stretchr/testify v1.8.4 (last version)
>go version
go version go1.21.6 darwin/arm64
>go test -v -coverprofile=coverage.txt -covermode count
=== RUN TestRun
=== RUN TestRun/TestISuite1
--- PASS: TestRun (0.05s)
--- PASS: TestRun/TestISuite1 (0.00s)
PASS
coverage: [no statements]
ok mytests/tests 0.586s
>cat coverage.txt
mode: count
Does your code actually have any statements?
Yes, I have code which work with DB. But I tried to write "test code" and find the problem. I got the same empty coverage.
Can you share a compilable recreate?
Please comment, or start a discussion (tab up top), if you still have this issue.
I used this part of the testify https://github.com/stretchr/testify?tab=readme-ov-file#suite-package And my test look like
And I try to fetch coverage tests by command
go test -v -coverprofile=coverage.txt -covermode count
But I have just empty coverage.txt and messagecoverage: [no statements]
Output run of testsCan you explain, how get coverage tests?