Unit testing with asserts: Why is assertHandler required to throw?

Nick Sabalausky a at a.a
Sun Jan 31 21:44:09 PST 2010


"Trip Volpe" <mraccident at gmail.com> wrote in message 
news:hk583n$28eb$1 at digitalmars.com...
> Nick Sabalausky Wrote:
>> The deferAssert module (possible name change and other API improvements
>> pending) of my SemiTwist D Tools library (
>> http://www.dsource.org/projects/semitwist ) is designed to get around 
>> those
>> problems.
>
> Good to know I'm not the only one who's had to working around this. :-P 
> Considering how D has unit testing and contract programming built-in 
> already, I'm still a bit surprised it doesn't have assertions and 
> expectations that are actually useful for people doing heavy unit testing.
>
> deferAssert is interesting, but it seems to require a lot of boilerplate. 
> The combination of mixin and template syntax is a bit kludgy, heh.
>

Yea, that's one of the reasons I like to push for a better string mixin 
syntax whenever the topic comes up. But it's the best I've been able to do 
in D1 without resorting to JUnit-style garbage like 
"expectTrue(a.logicalOr(b).logicalAnd(c.greaterThan(d)))" or whatever the 
actual JUnit gibberish is (and I don't even have to abuse operator 
overloading either). Though, it's still a lot better than what I'd be able 
to do in most languages. 





More information about the Digitalmars-d mailing list