Skip to content

Commit

Permalink
Merge pull request #1267 from hcoles/bug/report_junit5_scan_errors
Browse files Browse the repository at this point in the history
Expand test api to allow logging of errors during test discovery
  • Loading branch information
hcoles authored Oct 23, 2023
2 parents 69a181f + b22c2ff commit 7aa83f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;

import static java.util.concurrent.TimeUnit.NANOSECONDS;
Expand Down Expand Up @@ -42,7 +43,12 @@ public void executionStarted(Description description, boolean suppressParallelWa
}

@Override
public void executionFinished(Description description, boolean passed) {
public void executionFinished(Description description, boolean passed, Throwable maybeError) {

if (maybeError != null) {
LOG.log(Level.SEVERE, description.toString(), maybeError);
}

Long t0 = startTimes.remove(description);
int executionTime;
if (t0 == null) {
Expand Down Expand Up @@ -70,4 +76,5 @@ public void executionFinished(Description description, boolean passed) {

invokeQueue.recordTestOutcome(description, passed, executionTime);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public void executionStarted(Description description) {
}

@Override
public void executionFinished(Description description, boolean passed) {
public void executionFinished(Description description, boolean passed, Throwable error) {
//noop
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ default void executionStarted(Description description) {
default void executionStarted(Description description, boolean suppressParallelWarning) {
executionStarted(description);
}
void executionFinished(Description description, boolean passed);

default void executionFinished(Description description, boolean passed) {
executionFinished(description, passed, null);
}

void executionFinished(Description description, boolean passed, Throwable error);
}

0 comments on commit 7aa83f9

Please sign in to comment.