Question about unittests

Alexander Panek a.panek at brainsware.org
Wed Jan 10 05:36:49 PST 2007


mfeathers wrote:
> 
> I was looking at the spec and it mentions that "unittest" is a special 
> method in classes.
> 
> Can you have more than one unittest method in a class?
> 

Unittests are actually not methods inside classes, but more statement 
blocks that are executed when you compile & execute unittests. So, they 
work as if you provide a void main () {}  in every file/class/whatever 
scope you put them in.

And yes, IIRC, you can have multiple unittest blocks per file, too. 
Though, they are all executed then. You could workaround that with 
version() { } blocks.


More information about the Digitalmars-d-learn mailing list