News for hackers. Stuff that matters.
Re:Stop requiring only one assertion per unit test: Multiple... by Phrodo_00 on Saturday November 05, 2022 @05:18PM (#33485884)
I think the advantage of having an assertion per test is that it makes sure that all of your assertions are executed. In a lot of test frameworks (that use exceptions for assertions for example) the first assertion fail will stop the test.

That doesn't mean you have to duplicate code, you can deal with it in other ways. In Junit I like to use @TestFctory [1] where I'll write most of the test in the Factory and then each assertion will be a Test the factory creates, and since they're lambdas they have access to the TestFactoy closure.

[1] https://junit.org/junit5/docs/current/user-guide/#writing-te...

Re:Stop requiring only one assertion per unit test: Multiple... by edgyquant on Saturday November 05, 2022 @05:25PM (#33485972)
This is a feature. I want it to fail fast so I can see the first issue not crawl the stack for error logs.
Re:Stop requiring only one assertion per unit test: Multiple... by un_montagnard on Saturday November 05, 2022 @06:14PM (#33486467)
I personally prefer seeing everything that I broke, not just the first one
Re:Stop requiring only one assertion per unit test: Multiple... by Izkata on Saturday November 05, 2022 @05:59PM (#33486312)
I vaguely remember a test framework I saw a decade+ ago that had both "assert*" to fail immediately and something else ("expect*" maybe?) to check and continue.