-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
sortWith() and orderWith() should respect @FixMethodOrder #1637
Comments
Makes sense to me. @stefanbirkner WDYT? |
Thanks @kcooney for the thoroughly introduction to the problem. IMHO we should implement this change. @kcooney do you have time to create a PR or should I implement the change. I have some free time during the next two days. I think we should not postpone 4.13 because of this change but instead target a 4.14 release within the next three month. We currently have a release candidate that seems to be ready for the final release. With a new change we need to create another release candidate that will delay the release again although IMO a lot of people are waiting for it. @kcooney @marcphilipp WDYT? |
@stefanbirkner I thought we weren't planning on having any releases after 4.13 (which is why we decided to deprecate I have limited free time right now, but this isn't a big change, so I might be able to find some time at the end of the week. |
You're right. There was a plan for 4.13 being the last release. @marcphilipp is this still valid? |
Yes, I think so unless there's a really good reason. Since |
@marcphilipp while I'll start looking into where we could apply the fixes. |
When you order a suite using
Request.sortWith()
all of the runners that implementSortable
(likeBlockJUnit4ClassRunner
) will reorder their methods using the passed-inComparator
, even if the ordering was specified with@FixMethodOrder
. The same holds true forRequest.orderWith()
. JUnit should instead not reorder methods for classes annotated with@FixMethodOrder
Background:
Someone at my company was trying to implement code to shuffle method orders to catch tests that produced different pass/fail results based on ordering (these shuffling tests are useful, for instance, if you want to ensure that you could always add
@Ignore
to a broken test without causing otherwise-passing tests to start failing). We have a very large code base, and some tests are annotated with@FixMethodOrder
because we know that they only pass if run in a specific order. We have enough of these that it will take a significant amount of time to fix them, especially for parts of the code where the original authors have left the company.We had to write custom shuffling code, because the code in JUnit for ordering did not respect
@FixMethodOrder
. In some cases, our customized shuffling code has to bail out with a "Shuffling not supported for this suite" error message.Can we please have
ParentRunner.sort(Sorter)
andParentRunner.order(Orderer)
do nothing if the Description indicates that the class was annotated with@FixMethodOrder
?I do realize that this would be a change in behavior from previous versions of JUnit. I don't think the change I'm proposing would cause tests to fail. The only way that could happen is if there is some code outside of JUnit that specifically orders the suite in an order, but if projects run into this problem when trying to migrate to 4.13, the easy work-around would be to remove the
@FixMethodOrder
annotation.The text was updated successfully, but these errors were encountered: