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

Specifying invocationCount, threadPoolSize and successPercentage causes tests to always pass #3172

Open
1 of 7 tasks
Yharooer opened this issue Sep 7, 2024 · 3 comments
Open
1 of 7 tasks

Comments

@Yharooer
Copy link

Yharooer commented Sep 7, 2024

Thank you for looking into #3170 so promptly, however I think there is another related issue.

TestNG Version

Note: only the latest version is supported

7.11.0-SNAPSHOT at f55ca8e

Expected behavior

Expect the following test to fail:

import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Test

class TestTest {
    @Test(invocationCount = 10, threadPoolSize = 10, successPercentage = 99)
    fun testTest() {
        assertThat(true).isFalse
    }
}

Actual behavior

The tests pass instead.

Correct behaviour is achieved if successPercentage is 100, or if threadPoolSize is omitted.

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

Please, share the test case (as small as possible) which shows the issue

import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Test

class TestTest {
    @Test(invocationCount = 10, threadPoolSize = 10, successPercentage = 99)
    fun testTest() {
        assertThat(true).isFalse
    }
}

Contribution guidelines

Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.

@Yharooer Yharooer changed the title Specifying invocationCount, threadPoolSize and successPercentage causes tests to always past Specifying invocationCount, threadPoolSize and successPercentage causes tests to always pass Sep 7, 2024
@krmahadevan
Copy link
Member

@Yharooer - I dont think this scenario would work because TestNG internally does the following:

When TestNG is given a combination of invocation count "m" + thread pool size of "n" it internally converts them into "m" test workers each having an invocation count of "1".

So for this example, it considers that there are 10 tests (equivalent to invocationCount) all running at the same time (since we have a threadpool size of greater than 1). So all the tests are likely to finish at the same time.

Since the tests are all going to be running concurrently it becomes difficult to consider the successPercentage attribute

@juherr - WDYT?

@juherr
Copy link
Member

juherr commented Sep 11, 2024

@krmahadevan If you think it is a bad practice to mix these attributes, add a warning message they are used together. It will help users they are not using it in the right way.

@Yharooer
Copy link
Author

I see.
Is it possible to check at the end of the tests that the successPercentage was achieved and override the test results? I think the same can be achieved by adding a custom listener to the test to check whether the failure rate was breached at the end of the tests. However it is inconvenient for users of TestNG to have to add this manually when from the user perspective it is not easy to understand why parallelisation should affect the result.

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