@@ -74,25 +74,29 @@ private void executeSuite(TestDescriptor test, JUnitReporter reporter) {
74
74
List <ScalatestTestDescriptor > tests = children .stream ().filter (c -> c instanceof ScalatestTestDescriptor )
75
75
.map (c -> (ScalatestTestDescriptor ) c ).collect (Collectors .toList ());
76
76
77
- Set <TestDescriptor > nonTests = new HashSet <>(children );
78
- nonTests .removeAll (tests );
77
+ Set <TestDescriptor > subSuites = new HashSet <>(children );
78
+ subSuites .removeAll (tests );
79
79
80
+ subSuites .stream ()
81
+ .sorted (Comparator .comparing (TestDescriptor ::getDisplayName ))
82
+ .forEach (c -> executeTest (c , reporter ));
83
+
84
+ boolean suitExecutedOk = true ;
80
85
if (!tests .isEmpty ()) {
81
- runScalatests ((ScalatestSuiteDescriptor ) test ,
86
+ suitExecutedOk = runScalatests ((ScalatestSuiteDescriptor ) test ,
82
87
tests .stream ()
83
88
.sorted (Comparator .comparing (TestDescriptor ::getDisplayName ))
84
89
.collect (Collectors .toList ()),
85
90
reporter );
86
91
}
87
92
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
+ }
93
97
}
94
98
95
- private void runScalatests (ScalatestSuiteDescriptor containingSuite , List <ScalatestTestDescriptor > tests , JUnitReporter reporter ) {
99
+ private boolean runScalatests (ScalatestSuiteDescriptor containingSuite , List <ScalatestTestDescriptor > tests , JUnitReporter reporter ) {
96
100
97
101
Suite scalasuite = containingSuite .getScalasuite ();
98
102
@@ -125,6 +129,7 @@ private void runScalatests(ScalatestSuiteDescriptor containingSuite, List<Scalat
125
129
try {
126
130
Status status = scalasuite .run (Option .apply (null ), args );
127
131
status .waitUntilCompleted ();
132
+ return true ;
128
133
} catch (Throwable e ) {
129
134
if (e instanceof InstantiationException || e instanceof IllegalAccessException ) {
130
135
reporter .apply (suiteAborted (args .tracker ().nextOrdinal (), e , Resources .cannotInstantiateSuite (e .getMessage ()), scalasuite ));
@@ -139,6 +144,7 @@ private void runScalatests(ScalatestSuiteDescriptor containingSuite, List<Scalat
139
144
throw e ;
140
145
}
141
146
}
147
+ return false ;
142
148
}
143
149
}
144
150
0 commit comments