My use case is the following: I have a folder with some files and would like to generate a unit test for every file. Since JUnit is not supporting anything like that I was thinking of using the SoftAssertions class instead. Unfortunately the test function itself is not under my control and uses JUnit assertions resulting in AssertionErrors.
I would like to catch those AssertionErrors and throw them again inside the SoftAssertions instance. I got two ideas for how this could work:
try {
doTest(something);
} catch (AssertionError e) {
softAssertions.rethrow(e);
}
of even simpler:
softAssertions.rethrow(() -> {
doTest(something);
});
the only thing possible as of today looks like this:
try {
doTest(something);
} catch (Throwable e) {
softAssertions.assertThat(e).isNull();
}
but this is not printing the stacktrace or any other details of the caught exceptions.
My use case is the following: I have a folder with some files and would like to generate a unit test for every file. Since JUnit is not supporting anything like that I was thinking of using the
SoftAssertionsclass instead. Unfortunately the test function itself is not under my control and uses JUnit assertions resulting inAssertionErrors.I would like to catch those
AssertionErrorsand throw them again inside theSoftAssertionsinstance. I got two ideas for how this could work:of even simpler:
the only thing possible as of today looks like this:
but this is not printing the stacktrace or any other details of the caught exceptions.