-
Notifications
You must be signed in to change notification settings - Fork 1k
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
TestNG 7.x DataProvider works in opposite to TestNG 6.x when retrying tests. #3041
Comments
If this is too much to ask, how about adding |
Another option is a new behavior configuration like we often did. |
The new features you propose sound great. You should propose them here: #3037 |
@juherr Did that. Though I'm confused as to whether call it an issue or a feature request. As said above, it's a regression issue; having it makes total sense. Having the opposite does too. @krmahadevan your thoughts? |
For history: the desired behavior exists up to 7.4.0. In 7.5.0 it has been broken, probably by one of many DataProvider related commits. Candidate for minor version fix, e.g. 7.9.1? |
@ubutar there have been some other merges as well which I feel shouldnt be part of a bugfix. So it will most likely be part of On a side note would you be willing to help raise a pull request for this? |
Closes testng-team#3041 We can now configure TestNG to enable/disable caching of test data produced by a data provider when TestNG is retrying a failed test method using the attribute “cacheDataForTestRetries” on the “@dataProvider” annotation. Below is a sample, which forces TestNG to re-invoke the data provider when a test method fails and it needs to be retried. ``` @dataProvider(name = "dp", cacheDataForTestRetries = false) public Object[][] getData() { return new Object[][] {{1}, {2}}; } ```
Closes testng-team#3041 We can now configure TestNG to enable/disable caching of test data produced by a data provider when TestNG is retrying a failed test method using the attribute “cacheDataForTestRetries” on the “@dataProvider” annotation. Below is a sample, which forces TestNG to re-invoke the data provider when a test method fails and it needs to be retried. ``` @dataProvider(name = "dp", cacheDataForTestRetries = false) public Object[][] getData() { return new Object[][] {{1}, {2}}; } ```
Closes #3041 We can now configure TestNG to enable/disable caching of test data produced by a data provider when TestNG is retrying a failed test method using the attribute “cacheDataForTestRetries” on the “@dataProvider” annotation. Below is a sample, which forces TestNG to re-invoke the data provider when a test method fails and it needs to be retried. ``` @dataProvider(name = "dp", cacheDataForTestRetries = false) public Object[][] getData() { return new Object[][] {{1}, {2}}; } ```
TestNG Version
7.9 (compared vs 6.8)
Expected behavior
TestNG DataProviders are frequently used as data generators, when feeding the same data to a test makes no sense due to application constraints, thus, it is (was) expected that DataProvider method is called for every retry.
In TestNG 6, when a test fails and is retried using IRetryAnalyser, dataProvider is called again, and failed tests are retried with new data (I'm not sure if it picks the data from newly generated dataset under same index). More often than not, it's the same data, except the cases described above, but it's being read and fed once again. Quite often, though, such dataproviders return single object.
In early TestNG 7, when Test method was retried, DataProvider was called every time, but with no effect - original data was fed. This was fixed in #2884 was discussed in #763 and in #2885 and of course on StackOverflow
Actual behavior
So, since TestNG 7.8, data is being generated once. Every retry is being fed the original data.
Problem is, both make sense. Compared to v6, it's a regression and a pain when migrating to v7, for the mentioned case of "single object returned - but unique every time". For the sake of healthy test design, new behavior makes sense too - tests should fail once there is reason, and not be retried until they pass.
Is the issue reproducible on runner?
Test case sample
Additionally, I've thrown in a project on GitHub: testng6vs7 for easy comparing
Suggestions
I guess since both make sense and are in different versions of TestNG, both should be present in coming version. My suggestion is doing one of the following:
@Generator
instead of@DataProvider
, when calling for data is assumed on every retry. It could both substitute and accompany@DataProvider
@DataProvider
- which will be quite self-explanatory.It's not really clear to me personally what to do when there is NxM array of data is fed, and out of N tests, n1<N fail. Guess the best decision for the case of
alwaysRun=true
dataprovider would be execute it again, feed data from under the same index. And the rest should be responsibility of those who implementIRetryAnalyzer
The text was updated successfully, but these errors were encountered: