Description
The ordering introduced with #1130 is a great feature. Also the fact that the annotation is inherited is really helpful in some cases.
But when a parameterized test inherits an OrderWith annotation, its parameters get reordered as well.
Another case where this behaviour could be a problem would be a parameterized test with more than one test method, where you add an OrderWith annotation in order to sort the test methods but not the parameters.
As long as the parameters name value starts with "{index}" and the amount of parameters is <10 there is no problem, because the order remains the same (at least with the provided alphanumeric ordering). If there are >10 parameters, the alphabetical order is 1, 10, 11, 2, 3, ...
I could think of the following possibilites to solve this:
- OrderWith should only sort test methods - not parameters. You have enough control over the parameter order in the parameters method and that order should not get changed.
- Add leading zeros to the {index} placeholder value or add an additional placeholder that outputs the index with leading zeros.
- Add an ordering to use with the OrderWith annotation using the org.junit.runner.manipulation.Sorter.NULL sorter to be able to override an inherited ordering (only solves case 1)