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.

Reply via email to