Don't let test stop on failure

前端 未结 1 1449
花落未央
花落未央 2020-12-07 03:29

I\'m looking for the best practice for following (simplified) scenario:

@Test
public void someTest() {
  for(String          


        
相关标签:
1条回答
  • 2020-12-07 04:11

    First of all, it's not really the correct way to implement this. JUnit allows parametrizing tests by defining a collection of inputs/outputs with the Parametrized test runner. Doing it this way ensures that each test case becomes a unique instance, making test report clearly state which samples passed and which ones failed.

    If you still insist on doing it your way you should have a look at AssertJ's Soft Assertions which allow "swallowing" individual assertion failures, accumulating them and only reporting after the test is finished. The linked documentation section uses a nice example and is definitely worth reading.

    0 讨论(0)
提交回复
热议问题