-
Notifications
You must be signed in to change notification settings - Fork 71
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
Non-adjacent repeatable annotations do not work with @CartesianProductTest #447
Comments
@CartesianProductTest
Give me a bit of time to ponder the problem. |
I've been thinking about this. The way I see it, we have 3 options: the two @scordio already listed and to try and make the extension work with the annotation mismatch. The documentation update should be fairly straightforward. I have a hunch how the extension could detect such a scenario, but it would require more reflection and evaluation (increased complexity), which could make the extension both slower and harder to maintain, which could bring unintended downsides with it. Right now, I'm leaning towards updating the documentation and opening an issue which people can "upvote" if they want to see this feature implemented... Getting some more feedback would be great. |
I'm also for updating the documentation |
I just hit this issue myself. I had the following code:
and it was failing as it thought that the 2 boolean values were first and the The ordering is important to me as these tests are incremental with an extra parameter so I don't want to have to make the tests more difficult to read because of ordering |
We can't really do mix-and-match with the annotations because the annotation order is simply not preserved at all. For example: @CartesianProductTest
@CartesianValueSource(ints = {1,2,3})
@IntRangeSource(from = 0, to = 5)
@CartesianValueSource(ints = {1,2,3})
void testInts(int i1, int i2, int i3) {
} becomes @CartesianProductTest
@CartesianValueSources({
@CartesianValueSource(ints = {1,2,3})
@CartesianValueSource(ints = {1,2,3})
})
@IntRangeSource(from = 1, to = 5)
void testInts(int arg0, int arg1, int arg2) {
} Which is not correct, but works. I'm fairly certain it's not possible to determine the original order of the annotations, therefore we can't "fix" this error. I recommend you do either of these:
|
Investigated this issue a bit further - we could accommodate special edge cases. It would require careful checking of parameter types and arguments provided from the annotations. The risk of introducing unwanted side-effects seem high. I'm kind of at my wits end. If someone else has a good solution for this, feel free to open a PR or propose a solution, EDIT: Okay, I've asked for advice and this can be easily solved if we just add |
I thought about improving the error message. Does the extension work if m out of n parameters (m < n) use this extension, but it's not the first m? If not, then:
Sounds like a lot of work for an error case, though. |
The new recommendation for anyone encountering this issue is: try (...and if you still have trouble, feel free to open a new issue.) |
While working on #414, I realized there is a nasty issue when repeatable annotations have other annotations (repeatable or not) in between.
Take this example:
The test execution will fail with:
This is due to the fact that the absolute declaration order of repeatable annotations is not kept when accessing them via reflection, as each group is encapsulated in the container annotation (still keeping the relative order, though).
So, when the extension invokes the corresponding argument providers, the order of:
is actually:
and an
int
value is proposed to the second parameter, which is along
, hence the exception.At the moment I don't see any way to solve this, but I'm far from being an expert on this topic.
What I see is that the error message does not help an end-user who is not fully familiar with how repeatable annotation ordering works under the hood (like me 🙂). He will not understand that reordering the annotations, and the corresponding parameters, is needed to make the test work.
I think the docs should be enhanced to mention this limitation. Changing annotations and parameters order should not be an issue for the users.
Another option could be to make the extension able to detect those cases and fail with a better message, but I'm not sure it is possible.
Any thoughts?
The text was updated successfully, but these errors were encountered: