News for hackers. Stuff that matters.
Re:Stop requiring only one assertion per unit test: Multiple... by mrits on Saturday November 05, 2022 @10:26AM (#33481766)
22 assertions in a test is a lot better than 22 separate tests that fail for the same reason.
Re:Stop requiring only one assertion per unit test: Multiple... by bluGill on Saturday November 05, 2022 @10:40AM (#33481900)
They are the same. I don't care, as I'll fix them one at a time, and if the fix happens to fix more than one great.
Re:Stop requiring only one assertion per unit test: Multiple... by mrits on Saturday November 05, 2022 @11:03AM (#33482134)
Fixing one at a time like that is a good way to get into an endless cycle. Zoom out a bit and make a plan before you start coding.
Re:Stop requiring only one assertion per unit test: Multiple... by bluGill on Saturday November 05, 2022 @12:59PM (#33483268)
That should be understood wothout saying. Even with a plan I'm going to fix one at a time.
Re:Stop requiring only one assertion per unit test: Multiple... by Jabbles on Saturday November 05, 2022 @03:20PM (#33484695)
With 22 separate tests you have the possibility of knowing that only a subset of them fail. Knowing which fail and which pass may help you debug.

In Go, in general, tests fail and continue, rather than causing the test to stop early, so you can tell which of those 22 checks failed. Other languages may have the option to do something similar.

https://pkg.go.dev/testing#T.Fail