First of all, this is not the right way to implement this. JUnit allows you to parameterize tests by defining a collection of inputs / outputs with the Parametrized test runner. The implementation of this method ensures that each test case becomes a unique instance in which the test report clearly indicates which samples passed and which failed.
If you still insist on doing it your own way, you should take a look at AssertJ Soft Assertions , which allow you to βswallowβ individual statement failures, accumulating them only after the test is completed. The related documentation section uses a good example and is definitely worth a read.
source share