Question about unittests
mfeathers
mfeathers at objectmentor.com
Wed Jan 10 05:48:08 PST 2007
Thanks. Another quick question. Is "assert" legal syntax outside of
contacts and unit tests? For instance, can I do this:
unittest {
someMethod();
}
void someMethod() {
assert 0 == 1
}
Michael Feathers
Alexander Panek wrote:
> 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