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
I have a suite of unit tests that check the output of my program. To ensure that there is no unchecked output, I use the following code:
type Suite struct {
output bytes.Buffer
}
func (s *Suite) Output() string {
defer s.output.Reset()
return s.output.String()
}
func (s *Suite) TearDownTest(c *check.C) {
if out := s.Output(); out != "" {
c.Logf("Unchecked output; check with: c.Check(s.Output(), check.Equals, %q)", out)
}
}
Using c.LogF hides the output though, since successful tests don’t log anything. Using c.ErrorF instead of c.LogF reports that the fixture panicked, which is also not what I intended when I wrote that code. I had expected that I can use c.ErrorF in the TearDownTest exactly as I can use it in the actual unit test, having it print the nice “obtained—expected” message.
The current API doesn’t allow me to query whether the test panicked, I can only ask c.Failed().
Is the above code something that check should support?
The text was updated successfully, but these errors were encountered:
I have a suite of unit tests that check the output of my program. To ensure that there is no unchecked output, I use the following code:
Using
c.LogF
hides the output though, since successful tests don’t log anything. Usingc.ErrorF
instead ofc.LogF
reports that the fixture panicked, which is also not what I intended when I wrote that code. I had expected that I can usec.ErrorF
in theTearDownTest
exactly as I can use it in the actual unit test, having it print the nice “obtained—expected” message.The current API doesn’t allow me to query whether the test panicked, I can only ask
c.Failed()
.Is the above code something that
check
should support?The text was updated successfully, but these errors were encountered: