With the appropriate logging of each assertion in there.
Consider the situation of "I've got an object and I want to make sure it comes out in JSON correctly"
The "one assertion" way of doing it is to assertEqual the entire json blob to some predefined string. The test fails, you know it broke, but you don't know where.
The multiple assertions approach would tell you where in there it broke and the test fails.
The point is much more one of "test one thing in a test" but testing one thing can have multiple assertions or components to it.
You don't need to have testFirstNameCorrect() and testLastNameCorrect() and so on. You can do testJSONCorrect() and test one thing that has multiple parts to verify its correctness. This becomes easier when you've got the frameworks that support it such as the assertAll("message", () -> assertSomething, () -> assertSomethingElse(), ...)
Aside from that, you could do things like
With the appropriate logging of each assertion in there.Consider the situation of "I've got an object and I want to make sure it comes out in JSON correctly"
The "one assertion" way of doing it is to assertEqual the entire json blob to some predefined string. The test fails, you know it broke, but you don't know where.
The multiple assertions approach would tell you where in there it broke and the test fails.
The point is much more one of "test one thing in a test" but testing one thing can have multiple assertions or components to it.
You don't need to have testFirstNameCorrect() and testLastNameCorrect() and so on. You can do testJSONCorrect() and test one thing that has multiple parts to verify its correctness. This becomes easier when you've got the frameworks that support it such as the assertAll("message", () -> assertSomething, () -> assertSomethingElse(), ...)
https://stackoverflow.com/q/40796756