diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java index 45f1c5003c..432af04b66 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java @@ -34,6 +34,8 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.Deque; import java.util.LinkedHashMap; import java.util.List; @@ -151,7 +153,22 @@ public void testSetCompleted( WrappedReportEntry testSetReportEntry, TestSetStat showProperties( ppw, testSetReportEntry.getSystemProperties() ); - for ( Entry>> statistics : classMethodStatistics.entrySet() ) + List>>> classMethodStatisticsEntries = + new ArrayList<>( classMethodStatistics.entrySet() ); + + Collections.sort( classMethodStatisticsEntries, + new Comparator>>>() + { + @Override + public int compare( Entry>> o1, + Entry>> o2 ) + { + return o1.getKey().compareTo( o2.getKey() ); + } + } + ); + + for ( Entry>> statistics : classMethodStatisticsEntries ) { for ( Entry> thisMethodRuns : statistics.getValue().entrySet() ) {