-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Milestone
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.10 windows/amd64
What did you do?
Run the following program with "go test":
helper.go:
package helperhelper_test.go:
package helper
import (
"testing"
)
func TestRun(t *testing.T) {
run(t, []string{"a", "b", "c"}) // this is line 8
}
func run(t *testing.T, values []string) {
t.Helper()
for _, value := range values {
t.Run("", func(t *testing.T) {
t.Helper()
t.Fatal(value) // this is line 16
})
}
}What did you expect to see?
--- FAIL: TestRun (0.00s)
--- FAIL: TestRun/#00 (0.00s)
...\subtest_test.go:8: a
...
What did you see instead?
--- FAIL: TestRun (0.00s)
--- FAIL: TestRun/#00 (0.00s)
...\subtest_test.go:16: a
...
The reported error line is 16 instead of 8, where the test data are defined. This makes it difficult to use the Run method to define a generic test on a list of cases. I would expect the Run method to be marked as a test helper by default. If the subtesting function is marked as helper, the reported line should be the line of the function that calls the Run method (unless skipped by the Helper mark).
Reactions are currently unavailable