I'm using JUnit assertion message to output some debugging information:
assertEquals(debugString, a, b);
Creation of this string is expensive, and I want to create it only if the assertion failed. How can I do this?
This is a bit of a hack, but you can simulate all the asserts yourself using if
s and fail
. E.g., instead of:
assertEquals(debugString, a, b);
Your test could have:
if (!a.equals(b)) {
fail (debugString);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With