3 ms·
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 exce
by Phrodo_00 4y ago
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-tests-dynamic-tests https://junit.org/junit5/docs/current/user-guide/#writing-te...
- edgyquant 4y agoThis is a feature. I want it to fail fast so I can see the first issue not crawl the stack for error logs.
- un_montagnard 4y agoI personally prefer seeing everything that I broke, not just the first one
- Izkata 4y agoI 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.