On 16 November 2012 00:36, Rupert Westenthaler <[email protected]> wrote: > Hi all, > > Short Version: > > * Developers: should check their test and make sure they do not assume > an certain execution order > * Users: Please help us by reporting failed Unit Test. Your issue is > most likely specific to the JVM you are using so we might not be aware > of the problem. Thanks! > > - - - > > Long Version with more details (for Stanbol Developers): > > Since about half a year there where occasionally problems with failed > unit tests caused by nondeterministic method ordering in some JVM > versions (see STANBOL-620). > > Ideally Unit Tests need to be independent and therefore the execution > order should not matter at all. However the fact was that a lot of > Unit Tests in Stanbol are not independent but assume an certain > execution oder (e.g. a CRUD test class that first creates, than > retrieves, updated and deletes items in multiple test methods). > > Initial the assumption was that with the release of junit-4.11 > execution orders will be re-assured, but as I discovered today this > was not the case (at least not out of the box). Because of that I > decided to fix affected Unit Tests [1-4].
Although it is a bad idea in general, if you need to fix the order for a test, you can do so using the new @FixMethodOrder annotation [1]. MethodSorters.JVM will not be consistent across runs or JVMs for the latest java6 and java7 runtimes, but some of the other MethodSorters are deterministic. Cheers, Peter [1] https://github.com/KentBeck/junit/blob/master/doc/ReleaseNotes4.11.md
