Skip to content

testing: invalid testing.go:1343: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test error #58129

@alexbrainman

Description

@alexbrainman

$ go version

I use play.golang.org website.

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

I use play.golang.org website.

What did you do?

I run this test

https://go.dev/play/p/BtIQcyQJYxR

What did you expect to see?

I expected to see this

=== RUN   TestRunFatal
=== RUN   TestRunFatal/Alex
    prog_test.go:11: Alex
--- FAIL: TestRunFatal (0.00s)
    --- FAIL: TestRunFatal/Alex (0.00s)
FAIL

Program exited.

This output is from slightly modified version of my test

https://go.dev/play/p/QeGIM_xxA4E

What did you see instead?

I see this

=== RUN   TestRunFatal
=== RUN   TestRunFatal/Alex
=== CONT  TestRunFatal
    prog_test.go:11: Alex
=== CONT  TestRunFatal/Alex
    testing.go:1343: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test
--- FAIL: TestRunFatal (0.00s)
    --- FAIL: TestRunFatal/Alex (0.00s)
FAIL

Program exited.

Perhaps I don't understand how tests work. But I was surprised and confused by the

    testing.go:1343: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test

error message. I also tried reading testing.FailNow documentation at

https://pkg.go.dev/testing#T.FailNow

The documentation talks about goroutines, but I don't have any goroutines in my test.

Thank you for investigating this.

Alex

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions