On Saturday, 9 May 2015 at 00:24:45 UTC, Andrei Alexandrescu wrote:

The issues with unittests are legit, albeit fixable. It's goofy to run the program after unittests, and unittests should have names that can be introspected, selected etc. I couldn't find much merit with the rest of the list. -- Andrei

Those are really the only ones that I've ever thought made sense, and in several cases, the things that folks want are things that I very much _don't_ want (e.g. continuing to execute a unittest block after an assertion failure). However, while it _is_ a bit goofy that the unit tests run just prior to the program running, it's easy enough to work around that I've never considered it a big deal. Maybe the solution would be to simply make it so that main gets replaced when you compile with -unittest rather than forcing you to do something like

version(unittest) void main() {}
else void main()
{
    ...
}

It's the lack of unit test names that poses a potentially big problem for large projects. But even that shouldn't be hard to fix - especially when unittest blocks are already functions with names to begin with; it's just that you can't name them yourself. But at least their names have their line number in them now. That didn't used to be the case, which was even worse - though I'm willing to bet that most folks don't realize that the unittest block's line number is in its function name.

- Jonathan M Davis

Reply via email to