Skip to content

Commit 9686ed0

Browse files
committed
Skip JUnit report parsing if no reports are found
1 parent c14179a commit 9686ed0

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/main/java/de/donnerbart/split/TestSplit.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,26 @@ public void run() throws Exception {
8383
// analyze JUnit reports
8484
final var junitPaths = getPaths(workingDirectory, junitGlob, null);
8585
LOG.info("Found {} JUnit report files", junitPaths.size());
86-
var slowestTest = new TestCase("", 0d);
87-
final var xmlMapper = new XmlMapper();
88-
for (final var junitPath : junitPaths) {
89-
final var testSuite = xmlMapper.readValue(junitPath.toFile(), TestSuite.class);
90-
final var testCase = new TestCase(testSuite.getName(), testSuite.getTime());
91-
if (classNames.contains(testCase.name())) {
92-
if (testCases.add(testCase)) {
93-
LOG.debug("Adding test {} [{}]", testCase.name(), formatTime(testCase.time()));
86+
if (!junitPaths.isEmpty()) {
87+
var slowestTest = new TestCase("", 0d);
88+
final var xmlMapper = new XmlMapper();
89+
for (final var junitPath : junitPaths) {
90+
final var testSuite = xmlMapper.readValue(junitPath.toFile(), TestSuite.class);
91+
final var testCase = new TestCase(testSuite.getName(), testSuite.getTime());
92+
if (classNames.contains(testCase.name())) {
93+
if (testCases.add(testCase)) {
94+
LOG.debug("Adding test {} [{}]", testCase.name(), formatTime(testCase.time()));
95+
}
96+
} else {
97+
LOG.info("Skipping test {} from JUnit report", testCase.name());
98+
}
99+
if (testCase.time() > slowestTest.time()) {
100+
slowestTest = testCase;
94101
}
95-
} else {
96-
LOG.info("Skipping test {} from JUnit report", testCase.name());
97-
}
98-
if (testCase.time() > slowestTest.time()) {
99-
slowestTest = testCase;
100102
}
103+
LOG.debug("Found {} recorded test classes with time information", testCases.size());
104+
LOG.debug("Slowest test class: {} ({})", slowestTest.name(), formatTime(slowestTest.time()));
101105
}
102-
LOG.debug("Found {} recorded test classes with time information", testCases.size());
103-
LOG.debug("Slowest test class: {} ({})", slowestTest.name(), formatTime(slowestTest.time()));
104106
}
105107
// add tests without timing records
106108
classNames.forEach(className -> {

0 commit comments

Comments
 (0)