Depends on the goal, automatic functional testing or unit testing. I sometimes do this for the first:
try { assertTrue(boolean condition from earlier in test method to check); } catch(AssertionError uhOh) { Logger.err("condition X failed: detailed info msg"); // broken item
Of course, using logback Logger and JUnit Assert.fail (), which does not execute the test method. Thus, I know all the failures for this method, and not the explosions after the first. In my case, I am testing a web application with rich content (dialogs and pages that require a lot of input).
The fail-fast downside (without catches) detects one problem, fixes it, starts it again and finds a new one (“rinse and repeat”), but if used for unit testing, this is an asset due to unit tests (ideally you check only one aspect of an element per test).
DYezek
source share