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

testing: handle panics in subtests in order to print errors and log info #25021

stephens2424 opened this issue Apr 23, 2018 · 6 comments
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.


Copy link

stephens2424 commented Apr 23, 2018

What version of Go are you using (go version)?


Does this issue reproduce with the latest release?


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

OS X, Windows, App Engine (playground)

What did you do?

What did you expect to see?

I expected to see the error that occurred to be printed, and then the panic.

What did you see instead?

I see only the panic.

The exact use case I have is a table test where each subtest is using a different version of an external resource (message queue). An early subtest fails to perform some setup and leaves an internal thing in a bad state, so I expect my tests to not work fully at this point. However, because the later subtest panics when it encounters that bad state, the whole test function aborts without my previous calls to t.Error or t.Fatal (in the previous subtest) having their contents printed. Because of this, I lost critical error information that would have pointed me to the real issue with the earlier subtest's setup. Since the earlier subtest didn't print anything, its problem was not apparent.

@FiloSottile FiloSottile added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 24, 2018
@FiloSottile FiloSottile added this to the Go1.11 milestone Apr 24, 2018
Copy link

meirf commented May 9, 2018

This behavior has been around since 1.7, which is when subtest support was added.
(That's not to say this behavior is okay - just that it's unlikely there's a recent commit that's causing this.)

Copy link

ianlancetaylor commented Jun 29, 2018

CC @mpvl

Copy link

gopherbot commented Jul 15, 2018

Change mentions this issue: testing: handle panics in subtests to print previous output

@andybons andybons modified the milestones: Go1.12, Go1.13 Feb 12, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
Copy link

andrewmed commented Sep 19, 2019

Hi. This is "help wanted" and "needs fix".
Last commit is from Emmanuel Odeke, it adds missing test, but it is from February.
If help is still needed and no one objects, I am glad to pick this up.

@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Copy link

hanyangtay commented Feb 8, 2020

Change has fixed this.
This can be marked as resolved once the change is released.

Copy link

ianlancetaylor commented Feb 8, 2020

Thanks. We can close it now.

@ianlancetaylor ianlancetaylor modified the milestones: Backlog, Go1.14 Feb 8, 2020
@golang golang locked and limited conversation to collaborators Feb 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
None yet

No branches or pull requests

9 participants