Search code examples
javamavenmaven-surefire-pluginsurefire

what's the order surefire-plugin execute test case?


based on Does Maven Surefire execute test cases sequentially by default?, I know that the surefire execute test cases sequentially, in other words, One by One.


I want to know which test cases executed first and which next, Through output information of surefire, I find that the order maybe random, for example:

  • test
  • boyTest.java

  • subdir

    • girlTest.java
  • parentTest.java the test directory has three test case: and the testcase execute order is girlTest.java, parentTest.java,boyTest.java

and So I want to make sure that whether the order that testCase executed is random


Solution

  • To verify that the ordering surefire used is the one you expect, run your build with debug enabled (-x flag). E.g. in my case I see the following:

    mvn clean install -X | grep runOrder
       ...
    <runOrder default-value="filesystem">hourly</runOrder>
    [DEBUG]   (s) runOrder = hourly
    

    By default order is not random but defined through how the file system returns the list of the tests (filesystem in surefire terms).

    There are other available orderings which you can choose through surefire.runOrder property (one of which is random).

    For more information see Surefire plugin runOrder