dev@glassfish.java.net

randomize junit test order

From: Bill Shannon <bill.shannon_at_oracle.com>
Date: Sat, 25 Feb 2012 12:26:41 -0800

I've run into a few cases recently where a junit test had an order
dependency, causing it to fail on one of my machines. What I'd like
is a way to randomize the order of tests within a test file.

Looking at
http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html
It looks like setting runOrder=random will cause the test *files* to
be run in random order (at least, that's the way I interpret it based
on the default value being "filesystem"), but what I want is the tests
within each test file to run in random order.

I found this plugin http://randomjunit.sourceforge.net/ that seems to
do what I want, except that it requires modifying the tests themselves
to specify that you want to run them in random order.

I'm really looking for something that we can configure in pom.xml
without needing to change any tests. Does anyone know how to do this?