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

Parallel method in suite tests not triggering linting errors #229

Open
nek1kek opened this issue Feb 25, 2025 · 1 comment
Open

Parallel method in suite tests not triggering linting errors #229

nek1kek opened this issue Feb 25, 2025 · 1 comment
Labels
question Further information is requested

Comments

@nek1kek
Copy link

nek1kek commented Feb 25, 2025

Hello testifying maintainers,

I am encountering an issue where the testifylint does not flag improper use of t.Parallel() within the testify suite structures. According to testify's practice and concurrency model, using t.Parallel() directly within suite-methods should be avoided as it can lead to race conditions or unexpected behaviors in the context of suite test execution. However, the linter does not report this.

example:

type ParallelRaise struct {
    suite.Suite
}

func TestRunFESAPIUZSuite(t *testing.T) {
    t.Parallel()
    suite.Run(t, new(ParallelRaise))
}

func (s *ParallelRaise) TestReceiptEndpoint() {
    s.T().Parallel()
    s.Run("Test_raise_parallel", func() {
        s.T().Parallel()
        s.Assert().Greater(2, 1)
    })
    s.Run("Test_raise_parallel_v2", func() {
        s.T().Parallel()
        s.Assert().Greater(2, 1)
    })
}

type MySuite struct {
    suite.Suite
}

func (s *MySuite) SetupTest() {
    s.T().Parallel()
}

func (s *MySuite) TestSomething() {
    s.T().Parallel()
    s.Run("1", func() {
        s.T().Parallel()
    })

    s.T().Run("2", func(t *testing.T) {
        t.Parallel()
    })
}
@Antonboom
Copy link
Owner

Antonboom commented Feb 26, 2025

@Antonboom Antonboom added the question Further information is requested label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants