suite: allow Suite methods to take *testing.T parameter#1255
suite: allow Suite methods to take *testing.T parameter#1255grongor wants to merge 2 commits intostretchr:masterfrom
Conversation
|
Just a few days ago I saw this PR and though that it's a shame it didn't get merged, so...thank you for taking another look! 🙇 🚀 |
|
I think we should go further and also allow |
|
Sure, could be useful :) But then:
So to make this truly universal and flexible we'd need to compare the list of parameters with the "list of allowed values" (containing If you want I can look into it ;) If you choose to keep it simple with "just the T", it's imo perfectly reasonable too :) |
Co-authored-by: Olivier Mengué <dolmen@cpan.org>
|
The panic on mis-matched signature can be resolved by #1665, this PR only addresses changing the signature change. Changing the signature would conflict with #1109 if in the future we fix the pseudo-inheritance in suite. Is Adding *assert.Assert as an optional argument as well as *testing.T; what about both? Would the order matter? This seems a little bit like like pretending Go has keyword args. The suite package already suffers from an incompatibility with Parallel testing because suite employed a pseudo-inheritance structure. The assert package suffers from unclear argument type validation because the |
brackendawson
left a comment
There was a problem hiding this comment.
You've not updated the package documentation.
Summary
Allow suite methods to take
*testing.Tparameter (as normal tests do). This is BC, and we are already messing with reflection there, so no penalties either.Changes
Extend allowed suite method signature to include optional
*testing.T.Fail with a friendly error when the signature doesn't match (before it panicked).
Motivation
There are many places where you need
t, like for example for mocks and other testing libraries. And typings.T()get's tedious after a while, and is completely avoidable at no cost :)