I don't get it. version(unittest) can't seem to use local variable
H. S. Teoh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 12 20:33:17 PDT 2014
On Sun, Jul 13, 2014 at 02:35:11AM +0000, dysmondad via Digitalmars-d-learn wrote:
[...]
> So, what is the generally accepted way include unit testing? TDD is
> all the rage these days and I though I would try my hand at it as well
> as D.
Just include unittest blocks in your program and compile with -unittest.
Example:
unittest {
assert(myNewFunc(1,2,3) == 456);
... // whatever else to verify it
}
auto myNewFunc(int x, int y, int z) {
... // code here
}
The program will run all unittests on startup before main() executes, so
you can just run it as usual. If any unittests fail it will abort with
an error message.
T
--
What's a "hot crossed bun"? An angry rabbit.
More information about the Digitalmars-d-learn
mailing list