-
Notifications
You must be signed in to change notification settings - Fork 163
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
Should I expect the dataprovider to run 3x if there are 3 tests? #93
Comments
Here is a simplified version of the code above. It will process just strings (so you can attempt locally). `@RunWith(DataProviderRunner.class)
}` The TestScriptHandler is an external class.
Stymied in Seattle. |
Hi @BrianJavaJazz, sorry but I am currently on a business trip and maintaining this in my spare time. I will have a look as soon as possible (at latest on the weekend). Cheers, |
Maybe I can try to answer the question. I think there is currently no way to tell the JUnitDataProvider runner to not call the data provider method each time. However, you can easily fix this yourself by just storing the results in a static variable and returning the variable once it has been generated. Like in your first example, where you even store the values in a static variable. You could modify that as follows:
|
aaschmid and janschaefer, Thank you both for your replies. janschaefer, that is pretty close to what I implemented just yesterday. In the external class which handles the data (where the dataprovider gets it's data) I have:
Thank you both. Cheers! Brian |
Hi @BrianJavaJazz, you found an issue in the junit-dataprovider which needs to get fixed. Does the workaround provided by @janschaefer help so far. Unfortunately, I have no good idea for any better one ... How urgent is it with the workaround in mind? Cheers, |
Hello. Yes, the workaround is fine. I have no issues with it, and the urgency is no more than average. My main concern at the time was that a scan for the same data was costing my tests some extra time, but that was the only issue. Thank you for your continued communication. I appreciate it. Best regards, Brian |
in order to not call the same static dataprovider multiple times
in order to not call the same static dataprovider multiple times
Hi @BrianJavaJazz, finally I released the new version v1.13.0 containing this fix. Cheers, Edit: v1.13.1 contains the fix :-) |
* issue93-cache-reused-dataprovider-results: cache and reuse dataprovider results (#93)
* issue93-cache-reused-dataprovider-results: cache and reuse dataprovider results (#93)
I need to generate my data just once before 3 tests are run. Afterwards, I walk through the data and use each piece for the tests. For "this" entity type, test these things, then for the next entity type, test the same things, etc.
But as I increase the number of @Test-annotated tests which are run, the dataprovider will run additional times at startup. As it is getting the same data, this is unnecessary. It's possible I have this set up incorrectly.
Is this expected functionality? Is there a way to get the data a single time only?
I saw that issue #87 was similar, but not this exact issue.
Thank you!
Brian
JDK 1.8.0_121
JUnit 4.12.0
junit-dataprovider 1.12.0
eclipse STS 3.7.3
How about some code! Here is a simplified version of my test class and a secondary class which holds the data provider generator.
First, the test driver:
`
@RunWith(DataProviderRunner.class)
public class testdataprovider {
}
`
Then, the secondary class which generates the Object[][]. This class logs in to an internal website, get a list of specific items, (the generic list, not a list of generics) then puts them into the typedefObjectArray. The array is then returned.
`public class TestScriptHandler {
}
`
The text was updated successfully, but these errors were encountered: