Suggestion (ping Walter): Improve unit testing.
David B. Held
dheld at codelogicconsulting.com
Sat Apr 21 01:43:25 PDT 2007
Gregor Richards wrote:
> There are a number of improvements I'd like to see in D's unit testing
> framework. All of them are standard library changes, and I've made them
> work in Tango (as an external patch). If they were added to both Phobos
> and Tango, DSSS could easily run unit tests, which would improve its
> test suite.
>
> Here are two major problems I see with unit tests right now:
> 1) You can't run only unit tests, you are forced to run main() as well.
> 2) Unit testing doesn't actually output anything useful, it just works
> under the no-news-is-good-news principle.
> [...]
Yeah, these are good points. There are a few things that you want from
unit tests:
* Consistent design
This is already handled by the unittest mechanism, which is great.
However, a unit testing library that offers all the typical primitives
found in xUnit would be even greater. This would help a lot in common
reporting.
* Consistent invocation
This means that there is a standard, well-known way to run the tests.
Typically 'make test' is a good way. However, 'dmd -unittest foo.d' is
also a perfectly good way, as is 'foo.exe --unittest'. At any rate, it
doesn't really make sense that unittests are just functions that get
executed before main(). I'm pretty sure nobody expects that.
* Consistent output
This means that someone who has never seen your tests before can tell
whether they passed or failed. The problem with the
'no-gnus-is-good-gnus' principle is that it makes it difficult to tell
the difference between "the tests all passed" and "the tests didn't
run". Having a standard result summary makes it possible for automated
tools to parse the results and display them in alternative formats.
Dave
More information about the Digitalmars-d
mailing list