From 4c62b8f7b991bbde458b26ec7e522445604e42d7 Mon Sep 17 00:00:00 2001 From: Vijay Krishna Palepu Date: Mon, 26 Sep 2022 16:42:22 -0700 Subject: [PATCH] Add throwables in CheckTestHasFailedResultListener - adding a new property on CheckTestHasFailedResultListener to store all throwbales encountered. - printing the list of throwables from the result listener in MutationTestWorker. --- .../execute/CheckTestHasFailedResultListener.java | 6 ++++++ .../org/pitest/mutationtest/execute/MutationTestWorker.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java b/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java index d55cd6df3..d096ad88f 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/CheckTestHasFailedResultListener.java @@ -25,6 +25,7 @@ public class CheckTestHasFailedResultListener implements TestListener { private final List succeedingTests = new ArrayList<>(); private final List failingTests = new ArrayList<>(); + public final List throwables = new ArrayList<>(); private final boolean recordPassingTests; private int testsRun = 0; @@ -35,6 +36,11 @@ public CheckTestHasFailedResultListener(boolean recordPassingTests) { @Override public void onTestFailure(final TestResult tr) { this.failingTests.add(tr.getDescription()); + + if (tr.getThrowable() != null) { + // TO DO: expand the data that we capture from the throwable instance. + this.throwables.add(tr.getThrowable().getClass().descriptorString()); + } } @Override diff --git a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java index 084604250..4125e2f67 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java +++ b/pitest/src/main/java/org/pitest/mutationtest/execute/MutationTestWorker.java @@ -205,6 +205,12 @@ private MutationStatusTestPair doTestsDetectMutation(final Container c, private MutationStatusTestPair createStatusTestPair( final CheckTestHasFailedResultListener listener) { + + System.out.println("printing throwables!"); + for (String t : listener.throwables) { + System.out.println(t); + } + List failingTests = listener.getFailingTests().stream() .map(Description::getQualifiedName).collect(Collectors.toList()); List succeedingTests = listener.getSucceedingTests().stream()