testifylint icon indicating copy to clipboard operation
testifylint copied to clipboard

feature: report on usage `suite.T().Run` instead of `suite.Run`

Open ArtAndreev opened this issue 9 months ago • 4 comments

According to https://github.com/stretchr/testify/blob/db8608ed63f5bd9abdd03f669f5bb80569c114b6/suite/suite.go#L96 suite.Run should be used for running subtests instead of directly running subtests with testing.T.

I ran into some problems with invalid running subtests and want this linter to report such invalid usage.

ArtAndreev avatar Nov 10 '23 12:11 ArtAndreev

Hi, @ArtAndreev!

Thank you for request. Do you mean CONTRIBUTING.md#suite-run?

Could you provide the concrete example this concrete problems? 🙏

P.S. Why s.T() just not return trimmed interface? 🤔 Maybe we already have known issue in testify project?

Antonboom avatar Nov 10 '23 14:11 Antonboom

  1. https://github.com/stretchr/testify/issues/1139
  2. https://github.com/stretchr/testify/issues/889
  3. https://github.com/stretchr/testify/pull/510
  4. https://gophers.slack.com/archives/C92321HDJ/p1628032842014900?thread_ts=1627781651.013900&cid=C92321HDJ

Antonboom avatar Nov 10 '23 14:11 Antonboom

Hi!

The problem occurs very rarely, it's hard to understand why it happens. It raises data race between tests, but the only t.Parallel call is in function that runs suite.

I have just read CONTRIBUTING.md, looks like the unimplemented checks from it should be mentioned in README.md, so I wouldn't have raised this issue. Anyway, sorry for noise 🙂.

ArtAndreev avatar Nov 10 '23 15:11 ArtAndreev

Ah, already mentioned:

Also look at open for contribution checkers

Sorry for noise.

ArtAndreev avatar Nov 10 '23 15:11 ArtAndreev