Skip to content

Commit

Permalink
Expand test api to allow logging of errors during test discovery
Browse files Browse the repository at this point in the history
Logging is active only during coverage phase and mirrors that used
for exceptions with junit 4 and other frameworks which do not
execute code during discovery.
  • Loading branch information
hcoles committed Oct 23, 2023
1 parent 69a181f commit b22c2ff
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 b22c2ff

Please sign in to comment.