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

suite.T() no longer compatible with *testing.T (compatibility changed) #893

Closed
narqo opened this issue Feb 19, 2020 · 7 comments
Closed

Comments

@narqo
Copy link

narqo commented Feb 19, 2020

Probably, following #867

In 1.5.0 the behaviour of Suite.T() has been changed in a backwards-incompatible way, even though the release notes say there are only non-breaking changes.

Before 1.5.0 Suite.T() returned *testing.T while it returns custom TestingT interface now. So the code below is broken (note, the code is massively simplified from the real use cases):

type FooSuite struct {
    suite.Suite
}

func (suite *FooSuite) TestSomething() {
    // Cannot use 'suite.T()' (type TestingT) as type *testing.T 
    testSomethingT(suite.T())

    // Cannot use 'suite.T()' (type TestingT) as type testing.TB Type does not implement 'testing.TB'   
    // as some methods are missing: Error(args ...interface{}) Fail() Failed() bool ...
    testSomethingTB(suite.T())
}

func testSomethingT(t *testing.T) {}

func testSomethingTB(t testing.TB) {}
@narqo narqo changed the title suite.TestingT no longer compatible with *testing.T (compatibility changed) suite.T() no longer compatible with *testing.T (compatibility changed) Feb 19, 2020
@narqo
Copy link
Author

narqo commented Feb 19, 2020

A small note, the master version of the documentation no longer reflects the behaviour https://godoc.org/github.com/stretchr/testify/suite#Suite.T:

T retrieves the current *testing.T context.

@glesica
Copy link
Collaborator

glesica commented Feb 19, 2020

If you submit a PR we can do a 1.5.1 release.

@narqo
Copy link
Author

narqo commented Feb 19, 2020

I'd be happy, but I don't understand the direction in which suite's API goes. Shall I try to rollback the switch to interfaces in suite or is suite.testingT was expected to be testing.TB-compatible?

@glesica
Copy link
Collaborator

glesica commented Feb 19, 2020

I know there was some discussion around this, but I don't recall the outcome, @boyan-soubachov do you remember? If I get a minute today I'll try to find the PR I'm thinking of.

@boyan-soubachov
Copy link
Collaborator

We should definitely revert #867 then. Excuse me, my mistake. Didn't realise that we return *testing.T intentionally there

@boyan-soubachov
Copy link
Collaborator

#894 created to revert this. Thorough reviews and feedback would be greatly appreciated 🙏

@narqo
Copy link
Author

narqo commented Feb 20, 2020

I believe this one was fixed with 1.5.1

@narqo narqo closed this as completed Feb 20, 2020
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