unit test that show more than one failure

Andre Pany andre at s-e-a-p.de
Tue Jun 16 06:48:18 UTC 2020


On Tuesday, 16 June 2020 at 06:19:51 UTC, Joel wrote:
> I've tired different unit test libraries, but they jump out on 
> errors instead of just adding to failed numbers.
>
> I'm thinking like this:
>
> ```
> @("dummy");
> unittset {
>   0.shouldEqual(0);
>   1.shouldEqual(2);
>   2.shouldEqual(3);
> }
> ```
>
> Test: dummy
> test passed line 10: 0 is equal to 0
> test failed line 11: 1 is not equal to 2
> test failed line 12: 2 is not equal to 3
>
> 1 passed
> 2 failed
>
> The unit tests I tried would jump out on the first failure.

I assume most unit test frameworks doesn't work that way because
this violates the single responsibility principal. A test should
only test 1 thing. In your example you want to test multiple 
things
and this is an indicator that you should have multiple tests 
instead.

That said, it is of course possible that a unittest test framework
could work the way you propose, but it is not desired.

Kind regards
André


More information about the Digitalmars-d-learn mailing list