-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: T and B should implement -ln methods #12011
Comments
Why ? Those methods already have an implicit line break appended, how would these new methods improve this ? |
Same reasoning as for I often write things like
or
but when writing tests, I have to remember to use an alternate form:
|
I think the latter are clearer, having to remember that the -ln version adds a space between the arguments, as well as trailing |
If one agreed with you, this would be "unfortunate". T.Fatal already exists, it cannot be removed or changed, and having an alias is worse than having just one slightly badly named function. However, there's another point here: T.Fatal doesn't necessarily have to be understood as "print this fatal line". It's much rater a statement about the test (it ended fatally). It's not analogous to fmt or log. |
@davecheney that argument seems to apply just as much to I almost always want a space, so I use |
@dominikh sure, one could view it that way. I just filed this to register the fact that I've consistently felt that these are missing during a few years of writing Go tests. Even if unintentional, that's the impression I got after using the log and testing packages a bunch. |
We can't extend the TB interface so I have a preference to not add common methods to T and B, so TB doesn't look lacking. |
@bradfitz TB contains unexported methods, so it should be possible to extend it? |
Oh, pleasant surprise whenever evidence of past foresight is found. |
I don't have a position on those, we cannot change the past, but I don't see the argument for adding extra methods to testing to be compelling. |
eh ? |
@davecheney by "foresight" @bradfitz is referring to the
|
That's a nice trick. On Wed, 5 Aug 2015 08:49 Andrew Gerrand notifications@github.com wrote:
|
For consistency with other printing things, this is probably a good thing to do although barely worthwhile. |
I just noticed that t.Fatal and t.Error do insert the spaces between arguments (they call fmt.Sprintln), so this change doesn't make sense. It's still inconsistent with fmt/log, but it's probably too late to change now. I'm not sure how I didn't notice this before, though. The code in question doesn't look like it has changed since 2011. |
Like fmt and log, testing should provide -ln methods for T and B; that is,
Errorln
,Fatalln
,Logln
, andSkipln
.The text was updated successfully, but these errors were encountered: