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 dataProvider and successPercentage causes test to always pass #3170

Closed
1 of 7 tasks
Yharooer opened this issue Sep 1, 2024 · 2 comments · Fixed by #3171
Closed
1 of 7 tasks

Specifying dataProvider and successPercentage causes test to always pass #3170

Yharooer opened this issue Sep 1, 2024 · 2 comments · Fixed by #3171

Comments

@Yharooer
Copy link

Yharooer commented Sep 1, 2024

TestNG Version

7.10.2

Expected behavior

Expected that the following tests fail because 75% of the tests fail but successPercentage is 99.

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

public class TestTest {
    @Test(dataProvider = "test", successPercentage = 99)
    public void sampleTest(String string) {
        assertEquals(string, "1");
    }

    @DataProvider(name = "test")
    public Object[][] testProvider() {
        return new Object[][]{{"1"}, {"2"}, {"3"}, {"4"}};
    }
}

Actual behavior

All tests pass.

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.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

public class TestTest {
    @Test(dataProvider = "test", successPercentage = 99)
    public void sampleTest(String string) {
        assertEquals(string, "1");
    }

    @DataProvider(name = "test")
    public Object[][] testProvider() {
        return new Object[][]{{"1"}, {"2"}, {"3"}, {"4"}};
    }
}

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
Copy link
Author

Yharooer commented Sep 1, 2024

Note that this behaviour changed in TestNG 7.

In TestNG 6.14.3, for the tests above, only "3" and "4" fail, which is still not the correct behaviour.

This changes again at TestNG 6.8.15. AT TestNG 6.8.17, "3" and "4" fail but at TestNG 6.8.15, they all pass.

@Yharooer
Copy link
Author

Yharooer commented Sep 1, 2024

It seems like when using a data provider and successPercentage, TestNG is reporting all failed tests as SUCCESS_PERCENTAGE_FAILURE even when the failure rate is breaching.

When running this:

@Listeners({DebugTestListener.class})
public class TestTest {
    @Test(dataProvider = "test", invocationCount = 100, successPercentage = 99)
    public void sampleTest(String string) {
        assertEquals(string, "1");
    }

    @DataProvider(name = "test")
    public Object[][] testProvider() {
        return new Object[][]{{"2"}};
    }
}

all tests report SUCCESS_PERCENTAGE_FAILURE.

@Yharooer Yharooer changed the title Data Provider not working with Success Percentage Specifying dataProvider and successPercentage causes all tests to pass Sep 1, 2024
@Yharooer Yharooer changed the title Specifying dataProvider and successPercentage causes all tests to pass Specifying dataProvider and successPercentage causes test to always pass Sep 1, 2024
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

Successfully merging a pull request may close this issue.

1 participant