Skip to content

Commit

Permalink
Use SerializableThrowable to save to file
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardhusmann committed Nov 7, 2024
1 parent adb417e commit 081d7a3
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/eu/stamp_project/testrunner/runner/Failure.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Failure implements Serializable {
public final String fullQualifiedNameOfException;
public final String messageOfFailure;
public final String stackTrace;
public Throwable throwable; // Throwable is not present if Failure is read from surefire report
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;
Expand All @@ -31,7 +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 = exception;
this.throwable = new SerializableThrowable(exception);
}

public Failure(String testCaseName, String testClassName, String fullQualifiedNameOfException, String messageOfFailure, String stackTrace) {
Expand Down Expand Up @@ -68,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();
}
}

}

0 comments on commit 081d7a3

Please sign in to comment.