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

Print verbose output (-v) on failures #144

Closed
bep opened this issue Aug 27, 2022 · 4 comments
Closed

Print verbose output (-v) on failures #144

bep opened this issue Aug 27, 2022 · 4 comments

Comments

@bep
Copy link
Contributor

bep commented Aug 27, 2022

quicktest's output is much nicer when running with the -v flag, but it's not a great experience having that flag on all the time, and it's often a little fiddly to toggle it on and off in editors.

So, I would be happy if quicktest could make the verbose output the default on qt.Assert failures.

I was reminded about this by @rogpeppe 's fix here rogpeppe/go-internal#148 -- before that I always ran with the -v flag when using the testscripts package, which was annoying in general, because I only needed the verbose output when it failed.

@rogpeppe
Copy link
Contributor

Can you say specifically which output you're talking about please? An example would be helpful.

@bep
Copy link
Contributor Author

bep commented Aug 28, 2022

@rogpeppe a simple example below.

  • Printing the full got/want is often much easier to reason about than the diff (especially true for tests you haven't looked at in a while)
  • It also allows you to more or less copy/paste the got into want in the test.
func TestFoo(t *testing.T) {
	c := qt.New(t)
	c.Assert([]string{"a", "b", "c", "d"}, qt.DeepEquals, []string{"a", "b", "c"})
}
--- FAIL: TestFoo (0.00s)
go test -run TestFoo     
slicehelpers_test.go:70: 
    error:
      values are not deep equal
    diff (-got +want):
        []string{
            "a",
            "b",
            "c",
      -     "d",
        }
    stack:
      /Users/bep/dev/go/bep/helpers/slicehelpers/slicehelpers_test.go:70
        c.Assert([]string{"a", "b", "c", "d"}, qt.DeepEquals, []string{"a", "b", "c"})
go test -v -run TestFoo     
slicehelpers_test.go:70: 
  error:
    values are not deep equal
  diff (-got +want):
      []string{
          "a",
          "b",
          "c",
    -     "d",
      }
  got:
    []string{"a", "b", "c", "d"}
  want:
    []string{"a", "b", "c"}
  stack:
    /Users/bep/dev/go/bep/helpers/slicehelpers/slicehelpers_test.go:70
      c.Assert([]string{"a", "b", "c", "d"}, qt.DeepEquals, []string{"a", "b", "c"})

@frankban
Copy link
Owner

frankban commented Sep 5, 2022

This behavior was introduced as a fix for #33
Probably we can investigate being a bit smarter about cases in which verbose should be required.
Single line values really do not increase the noise.

@frankban
Copy link
Owner

#147 is an attempt to fix this. That's released as v1.14.4. Quicktest now only suppress the got/want args if they are longer than ten lines (and -v is not provided). We can adjust this gradually as required, but it should address the cases you provided, in which the output for args is one line. Closing this ticket, but please reopen it if the fix is not good enough!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants