File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed
src/main/java/org/testng/asserts Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 1
1
Current
2
+ New: Added a method in Assertion class to allow downstream TestNG consumers to override the error message (Ryan Laseter)
2
3
Fixed: GITHUB-165: @AfterGroups is not executed when group member fails or is skipped (Krishnan Mahadevan)
3
4
Fixed: GITHUB-118: @BeforeGroups only called if group is specified explicitly (Krishnan Mahadevan)
4
5
Fixed: GITHUB-182: Inherited test methods do not get expected group behavior (Krishnan Mahadevan)
Original file line number Diff line number Diff line change @@ -743,4 +743,21 @@ public void doAssert() {
743
743
}
744
744
});
745
745
}
746
+
747
+ /***
748
+ * Override this method should you want to change
749
+ * the default way Throwable objects are logged.
750
+ * @param error Throwable of the Assertion
751
+ * @return default throwable formatted message for TestNG
752
+ */
753
+ protected String getErrorDetails (Throwable error ) {
754
+ StringBuilder sb = new StringBuilder ();
755
+ sb .append (error .getMessage ());
756
+ Throwable cause = error .getCause ();
757
+ while (cause != null ) {
758
+ sb .append (" " ).append (cause .getMessage ());
759
+ cause = cause .getCause ();
760
+ }
761
+ return sb .toString ();
762
+ }
746
763
}
Original file line number Diff line number Diff line change @@ -37,12 +37,7 @@ public void assertAll() {
37
37
sb .append ("," );
38
38
}
39
39
sb .append ("\n \t " );
40
- sb .append (error .getMessage ());
41
- Throwable cause = error .getCause ();
42
- while (cause != null ) {
43
- sb .append (" " ).append (cause .getMessage ());
44
- cause = cause .getCause ();
45
- }
40
+ sb .append (getErrorDetails (error ));
46
41
}
47
42
throw new AssertionError (sb .toString ());
48
43
}
You can’t perform that action at this time.
0 commit comments