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

DataProvider with cacheDataForTestRetries = false Does Not Update Test Method Parameters on Retry in TestNG #3157

Open
2 of 7 tasks
Riabchykova opened this issue Aug 12, 2024 · 0 comments

Comments

@Riabchykova
Copy link

Riabchykova commented Aug 12, 2024

TestNG Version

7.10.2

Expected behavior

Regenerated (new) parameter value is passed to the test method on retry when DataProvider method contains attribute 'cacheDataForTestRetries = false'

Actual behavior

Original (initial) parameter value is passed to the test method on retry when DataProvider method contains attribute 'cacheDataForTestRetries = false'

Is the issue reproducible on runner?

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

Test case sample

package testpackage;

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

import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

public class TestngRetryDpTest extends BaseTest {

    @Test(dataProvider = "regenerateParametersOnRetryTest", retryAnalyzer = MyRetry.class)
    public void regenerateParametersOnRetryTest(UUID uuidTestParam) {

        logger.info("Param UUID: " + uuidTestParam.toString());
        assert 1 == 0;
    }

    @DataProvider(name = "regenerateParametersOnRetryTest", cacheDataForTestRetries = false)
    public Object[][] getData() {

        return new Object[][]{{UUID.randomUUID()}};
    }

    public static class MyRetry implements IRetryAnalyzer {

        private final AtomicInteger counter = new AtomicInteger(1);

        @Override
        public boolean retry(ITestResult result) {
            return counter.getAndIncrement() != 2;
        }
    }
}

The output during the test run is as follows:

INFO: Param UUID: 86f22958-ec9a-498a-a805-b940bc088955
INFO: Param UUID: 86f22958-ec9a-498a-a805-b940bc088955

While the DataProvider method is being called again, and I can see a newly generated UUID in the ParameterHandler.ParameterBag within the org.testng.internal.invokers.TestInvoker.retryFailed() method, it seems that the new value is not being propagated to the test method. Instead, the TestMethodArguments continues to hold the original value.

Relates to: #3076

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.

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

1 participant