You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What does 'go version' print?
1.3
What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. create a package
2. create a test case as example
3. run go test --cover
What happened?
the example does not contribute to the coverage
What should have happened instead?
the example should contribute to the coverage since it's
a test and run with go test
The text was updated successfully, but these errors were encountered:
I am unable to reproduce this. Coverage works fine with examples.
Are you including an "Output:" comment in your example function? If not, the example
won't be executed as a test. Use "go test -v" to make sure your examples are being
executed.
Here's my successful test run:
~/src/covertest $ cat foo.go
package foo
import "fmt"
func Foo() {
fmt.Println("yay")
}
~/src/covertest $ cat foo_test.go
package foo
func ExampleFoo() {
Foo()
// Output: yay
}
~/src/covertest $ go test -v -cover
=== RUN: ExampleFoo
--- PASS: ExampleFoo (0.00s)
PASS
coverage: 100.0% of statements
ok covertest 0.010s
The text was updated successfully, but these errors were encountered: