@@ -101,6 +101,12 @@ public void execute() throws MojoExecutionException {
101
101
}
102
102
103
103
final String runCommand = createRerunCommand (classnameToTestcaseList );
104
+
105
+ // previous run exited with code > 0, but all tests were actually run successfully
106
+ if (runCommand == null ) {
107
+ return ;
108
+ }
109
+
104
110
final StringBuilder rerunCommand = new StringBuilder (runCommand );
105
111
rerunCommand .append (buildProcessedMvnTestOpts (artifactId , groupId ));
106
112
if (rerunProfile != null ) {
@@ -245,13 +251,15 @@ public File[] getXmlFileList(File baseDir) {
245
251
* @return rerunCommand
246
252
*/
247
253
public String createRerunCommand (Map <String , List <String >> classnameToTestcaseList ) {
254
+ boolean hasTestsAppended = false ;
248
255
final StringBuilder retryRun = new StringBuilder ("mvn test" );
249
256
retryRun .append (" -Dtest=" );
250
257
// TODO: 04/02/2022 replace with Java 8 streams
251
258
for (String className : classnameToTestcaseList .keySet ()) {
252
259
List <String > failedTestCaseList = classnameToTestcaseList .get (className );
253
260
if (!failedTestCaseList .isEmpty ()) {
254
261
retryRun .append (className );
262
+ hasTestsAppended = true ;
255
263
if (failedTestCaseList .contains ("" )) {
256
264
retryRun .append ("," );
257
265
continue ;
@@ -267,6 +275,6 @@ public String createRerunCommand(Map<String, List<String>> classnameToTestcaseLi
267
275
}
268
276
}
269
277
}
270
- return retryRun .toString ();
278
+ return hasTestsAppended ? retryRun .toString () : null ;
271
279
}
272
280
}
0 commit comments