News for hackers. Stuff that matters.
Re:Stop requiring only one assertion per unit test: Multiple... by tharkun__ on Saturday November 05, 2022 @09:11AM (#33481092)
I think we also have to take into account how you work.

Are you working by yourself? Nobody else will ever see this code? Do whatever your timings tell you is best.

Are you working in a team or is this an open source project? In that case I think we need to do the thing that allows for the most variation. People that like having an overview of all the failures at once can only do so if you don't fail on the first error. If you do they have no workaround. If you show all of them though then your workaround is to simply only look at the first failure, ignoring the others.

Personally I do a hybrid approach. I want my test suite to continue through all tests and tell me everything that is wrong. If I change a small thing over here I definitely want to see whether I broke 3 or 4 unit tests around there or if I broke 37 test all around.

For fixing them I will go one by one after having done a quick survey of the types of failures. I. e. I might expect some of those failures due to the nature of my change. IDEs are really great here at least in my world. They allow me to very quickly run either a single test, a certain subset or the entire suite. After the one test I concentrated is green running all tests in that particular file again is just a click away. Now I am in overview mode again. I want to know what overall effect this one change had. Everything green again? Different subset broken? No change?

There are no comments on this comment yet.