Skip to content

Commit 2a7e4d9

Browse files
committed
Exit immediately if no failed tests are found.
1 parent d1b029d commit 2a7e4d9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.clevertap</groupId>
88
<artifactId>supertest-maven-plugin</artifactId>
99
<packaging>maven-plugin</packaging>
10-
<version>1.10</version>
10+
<version>1.11-SNAPSHOT</version>
1111
<description>A wrapper for Maven's Surefire Plugin, with advanced re-run capabilities.
1212
</description>
1313
<name>supertest-maven-plugin</name>

src/main/java/com/clevertap/maven/plugins/supertest/SuperTestMavenPlugin.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public void execute() throws MojoExecutionException {
101101
}
102102

103103
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+
104110
final StringBuilder rerunCommand = new StringBuilder(runCommand);
105111
rerunCommand.append(buildProcessedMvnTestOpts(artifactId, groupId));
106112
if (rerunProfile != null) {
@@ -245,13 +251,15 @@ public File[] getXmlFileList(File baseDir) {
245251
* @return rerunCommand
246252
*/
247253
public String createRerunCommand(Map<String, List<String>> classnameToTestcaseList) {
254+
boolean hasTestsAppended = false;
248255
final StringBuilder retryRun = new StringBuilder("mvn test");
249256
retryRun.append(" -Dtest=");
250257
// TODO: 04/02/2022 replace with Java 8 streams
251258
for (String className : classnameToTestcaseList.keySet()) {
252259
List<String> failedTestCaseList = classnameToTestcaseList.get(className);
253260
if (!failedTestCaseList.isEmpty()) {
254261
retryRun.append(className);
262+
hasTestsAppended = true;
255263
if(failedTestCaseList.contains("")) {
256264
retryRun.append(",");
257265
continue;
@@ -267,6 +275,6 @@ public String createRerunCommand(Map<String, List<String>> classnameToTestcaseLi
267275
}
268276
}
269277
}
270-
return retryRun.toString();
278+
return hasTestsAppended ? retryRun.toString() : null;
271279
}
272280
}

0 commit comments

Comments
 (0)