[Home]
[News Groups]
[Search]
[Books]
[DMC++ CD]
[D]
|
D's built in unit testing support makes it very convenient
to add tests for code right next to that code. This makes
for an effective management tool to ensure that unit testing
gets done and updated in parallel with the code.
In the most straightforward usage of unit testing in D, assert() is used for contract testing:
unittest
{
assert(x == 5);
}
and if the assert fails, it throws an AssertError
exception, which gets caught by the runtime library, a message
is printed, and it exits.
While this gets the essential job done, some programmers want more flexibility. For example, they'd like it to not stop on the first error, but to collect and log all the errors in one run. Here are some approaches for doing this:
|
|