Skip to content

MethodSorter METHOD_ORDER allowing to specify the execution order of test methods #1176

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

Closed
wants to merge 1 commit into from

Conversation

adamsiemion
Copy link

  • added attribute order to the Test annotation for specyfing the execution order
  • created a new MethodSorter (METHOD_ORDER) and added it to the MethodSorters enum
  • created a unit test for this feature

…ORDER allowing to specify test execution order
adamsiemion referenced this pull request in adamsiemion/junit Jul 3, 2015
…ORDER allowing to specify test execution order
@tobiasKaminsky
Copy link

This would be a great feature for me as it is more intuitive to have the tests executed in the same order as they are written.
Of course this only matters if the tests needs to be in a specific order.
Currently I avoid this problem by adding numbers to the front of the tests and use NAME_ORDER.

(And I know that a testsuite should work without a specific order, but in this case it is not possible :/ )

@cardil
Copy link

cardil commented Aug 26, 2015

👍 for this feature. BTW. Random order, just like Ruby rspec, whould be nice to!! Mayby I will do that in seperate PR

EDIT: Default sort is kinda random, doesn't it?

@tobiasKaminsky
Copy link

@cardil As far as I have understand and read the current sorting oder is random, but always the same for a specific computer and java machine.

@cardil
Copy link

cardil commented Aug 26, 2015

@tobiasKaminsky Yup. hashcodes for strings doesn't change beetween JVM executions. So, the truely random order would be nice.

BTW. This discusion is offtopic :-P so I've created new issue for that: #1194

@kcooney
Copy link
Member

kcooney commented Aug 29, 2015

There are many ways that people could want to specify the ordering of methods, so I personally would prefer that we added an extension point that allowed you to define your own class that does the ordering or sorting.

See #1130 for one way we could do that

@kcooney
Copy link
Member

kcooney commented Sep 18, 2016

I don't support specifying an ordering in the Test annotation. The JUnit team has long encouraged tests to not depend on ordering. While I can see why some projects might need to specify an ordering, I don't think adding support to the Test annotation would encourage it too strongly.

@kcooney kcooney closed this Sep 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants