{"action":"created","issue":{"url":"https://api.github.com/repos/junit-team/junit/issues/1194","labels_url":"https://api.github.com/repos/junit-team/junit/issues/1194/labels{/name}","comments_url":"https://api.github.com/repos/junit-team/junit/issues/1194/comments","events_url":"https://api.github.com/repos/junit-team/junit/issues/1194/events","html_url":"https://github.com/junit-team/junit/issues/1194","id":103209199,"number":1194,"title":"Truely random test order","user":{"login":"cardil","id":540893,"avatar_url":"https://avatars.githubusercontent.com/u/540893?v=3","gravatar_id":"","url":"https://api.github.com/users/cardil","html_url":"https://github.com/cardil","followers_url":"https://api.github.com/users/cardil/followers","following_url":"https://api.github.com/users/cardil/following{/other_user}","gists_url":"https://api.github.com/users/cardil/gists{/gist_id}","starred_url":"https://api.github.com/users/cardil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cardil/subscriptions","organizations_url":"https://api.github.com/users/cardil/orgs","repos_url":"https://api.github.com/users/cardil/repos","events_url":"https://api.github.com/users/cardil/events{/privacy}","received_events_url":"https://api.github.com/users/cardil/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-26T08:37:33Z","updated_at":"2015-09-27T03:00:16Z","closed_at":null,"body":"By default junit executes test in default order that is based on method name hash code. In java hashcodes of string doesn't change between executions, so the order is random, but constant for given computer. That could lead to unpredictable errors. \r\n\r\nRef: https://github.com/junit-team/junit/blob/master/src/main/java/org/junit/internal/MethodSorter.java#L13\r\n\r\n```bash\r\n$ groovysh \r\nGroovy Shell (1.8.6, JVM: 1.7.0_79)\r\nType 'help' or '\\h' for help.\r\n---------------------------------------------------------------------------------------------------------------------------------------------------------\r\ngroovy:000> a = 'testSample'\r\n===> testSample\r\ngroovy:000> a.hashCode()\r\n===> 1710059740\r\ngroovy:000>\r\n$ groovysh \r\nGroovy Shell (1.8.6, JVM: 1.7.0_79)\r\nType 'help' or '\\h' for help.\r\n---------------------------------------------------------------------------------------------------------------------------------------------------------\r\ngroovy:000> a = 'testSample'\r\n===> testSample\r\ngroovy:000> a.hashCode()\r\n===> 1710059740\r\ngroovy:000>\r\n```\r\n\r\nTo fix this enchantment, there should be truly random order option to explicitly specify in test case using `@FixMethodOrder`.\r\n\r\nThis will be similar to Rspec `--order random` option. Ref: http://blog.davidchelimsky.net/blog/2012/01/04/rspec-28-is-released/\r\n"},"comment":{"url":"https://api.github.com/repos/junit-team/junit/issues/comments/143514521","html_url":"https://github.com/junit-team/junit/issues/1194#issuecomment-143514521","issue_url":"https://api.github.com/repos/junit-team/junit/issues/1194","id":143514521,"user":{"login":"mrnichols76","id":10383890,"avatar_url":"https://avatars.githubusercontent.com/u/10383890?v=3","gravatar_id":"","url":"https://api.github.com/users/mrnichols76","html_url":"https://github.com/mrnichols76","followers_url":"https://api.github.com/users/mrnichols76/followers","following_url":"https://api.github.com/users/mrnichols76/following{/other_user}","gists_url":"https://api.github.com/users/mrnichols76/gists{/gist_id}","starred_url":"https://api.github.com/users/mrnichols76/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrnichols76/subscriptions","organizations_url":"https://api.github.com/users/mrnichols76/orgs","repos_url":"https://api.github.com/users/mrnichols76/repos","events_url":"https://api.github.com/users/mrnichols76/events{/privacy}","received_events_url":"https://api.github.com/users/mrnichols76/received_events","type":"User","site_admin":false},"created_at":"2015-09-27T03:00:16Z","updated_at":"2015-09-27T03:00:16Z","body":"I just submitted a pull request adding this feature.\r\nAs this is my first time to contribute, your feedback is especially important. Thanks!"}}