unittest "name" {}

Paul Backus snarwin at gmail.com
Thu Feb 16 23:21:11 UTC 2023


On Thursday, 16 February 2023 at 17:26:20 UTC, bachmeier wrote:
> My opinion is that naming a unit test is the wrong approach. If 
> the condition for an `enforce` statement fails, it returns an 
> informative message, not a name attached to the `enforce` 
> statement. Along those lines, I would prefer this:
>
> ```
> unittest {
>   onFailure("Comparison of transformations failed");
>   ...
> }
> ```

```
unittest
{
     import std.stdio;

     scope(failure) writeln("Test failed");
     assert(1 + 1 == 3);
}
```


More information about the Digitalmars-d mailing list