diff --git a/src/main/java/eu/stamp_project/testrunner/runner/Failure.java b/src/main/java/eu/stamp_project/testrunner/runner/Failure.java index c38b3d7..a251075 100644 --- a/src/main/java/eu/stamp_project/testrunner/runner/Failure.java +++ b/src/main/java/eu/stamp_project/testrunner/runner/Failure.java @@ -13,11 +13,14 @@ */ public class Failure implements Serializable { + private final static long serialVersionUID = 4319480863941757524L; + public final String testCaseName; public final String testClassName; public final String fullQualifiedNameOfException; public final String messageOfFailure; public final String stackTrace; + public SerializableThrowable throwable; // Throwable is not present if Failure is read from surefire report public Failure(String testCaseName, String testClassName, Throwable exception) { this.testCaseName = testCaseName; @@ -28,6 +31,7 @@ public Failure(String testCaseName, String testClassName, Throwable exception) { PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw); this.stackTrace = sw.toString(); // stack trace as a string + this.throwable = new SerializableThrowable(exception); } public Failure(String testCaseName, String testClassName, String fullQualifiedNameOfException, String messageOfFailure, String stackTrace) { @@ -64,4 +68,21 @@ public int hashCode() { result = 31 * result + (messageOfFailure != null ? messageOfFailure.hashCode() : 0); return result; } + + + public static class SerializableThrowable implements Serializable { + + private static final long serialVersionUID = 2988580623727952827L; + + public final String className; + public final String message; + public final StackTraceElement[] stackTrace; + + public SerializableThrowable(Throwable throwable) { + this.className = throwable.getClass().getName(); + this.message = throwable.getMessage(); + this.stackTrace = throwable.getStackTrace(); + } + } + } \ No newline at end of file