unittest "name" {}
bachmeier
no at spam.net
Thu Feb 16 17:26:20 UTC 2023
On Thursday, 16 February 2023 at 15:36:25 UTC, Steven
Schveighoffer wrote:
> I would couch this by saying, I don't really think we need
> anything here. The @("Johnny") is good enough for me. In fact,
> I'm fine without labeling unittests at all, and just looking at
> the file/line of the failed tests.
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");
...
}
```
Naming unit tests would open up other issues. Would you allow
recycling of names? There's no reason you couldn't have variable
foo and unittest foo, but that would be confusing to someone
learning the language. Would you have to use unique unittest
names if you import 30 modules written by someone else? This
could probably be resolved without great difficulty at the level
of language design, but it's all added complexity that you
shouldn't deal with when learning a language.
More information about the Digitalmars-d
mailing list