@@ -74,25 +74,29 @@ private void executeSuite(TestDescriptor test, JUnitReporter reporter) {
7474 List <ScalatestTestDescriptor > tests = children .stream ().filter (c -> c instanceof ScalatestTestDescriptor )
7575 .map (c -> (ScalatestTestDescriptor ) c ).collect (Collectors .toList ());
7676
77- Set <TestDescriptor > nonTests = new HashSet <>(children );
78- nonTests .removeAll (tests );
77+ Set <TestDescriptor > subSuites = new HashSet <>(children );
78+ subSuites .removeAll (tests );
7979
80+ subSuites .stream ()
81+ .sorted (Comparator .comparing (TestDescriptor ::getDisplayName ))
82+ .forEach (c -> executeTest (c , reporter ));
83+
84+ boolean suitExecutedOk = true ;
8085 if (!tests .isEmpty ()) {
81- runScalatests ((ScalatestSuiteDescriptor ) test ,
86+ suitExecutedOk = runScalatests ((ScalatestSuiteDescriptor ) test ,
8287 tests .stream ()
8388 .sorted (Comparator .comparing (TestDescriptor ::getDisplayName ))
8489 .collect (Collectors .toList ()),
8590 reporter );
8691 }
8792
88- nonTests .stream ()
89- .sorted (Comparator .comparing (TestDescriptor ::getDisplayName ))
90- .forEach (c -> executeTest (c , reporter ));
91-
92- reporter .getJunitListener ().executionFinished (test , TestExecutionResult .successful ());
93+ if (suitExecutedOk ){
94+ // if exception is thrown during suit execution (init, before/after all) we should not report a SUCCESS
95+ reporter .getJunitListener ().executionFinished (test , TestExecutionResult .successful ());
96+ }
9397 }
9498
95- private void runScalatests (ScalatestSuiteDescriptor containingSuite , List <ScalatestTestDescriptor > tests , JUnitReporter reporter ) {
99+ private boolean runScalatests (ScalatestSuiteDescriptor containingSuite , List <ScalatestTestDescriptor > tests , JUnitReporter reporter ) {
96100
97101 Suite scalasuite = containingSuite .getScalasuite ();
98102
@@ -125,6 +129,7 @@ private void runScalatests(ScalatestSuiteDescriptor containingSuite, List<Scalat
125129 try {
126130 Status status = scalasuite .run (Option .apply (null ), args );
127131 status .waitUntilCompleted ();
132+ return true ;
128133 } catch (Throwable e ) {
129134 if (e instanceof InstantiationException || e instanceof IllegalAccessException ) {
130135 reporter .apply (suiteAborted (args .tracker ().nextOrdinal (), e , Resources .cannotInstantiateSuite (e .getMessage ()), scalasuite ));
@@ -139,6 +144,7 @@ private void runScalatests(ScalatestSuiteDescriptor containingSuite, List<Scalat
139144 throw e ;
140145 }
141146 }
147+ return false ;
142148 }
143149 }
144150
0 commit comments