Assert and the optional Message
Jonathan M Davis
jmdavisProg at gmx.com
Sun Mar 11 14:12:05 PDT 2012
On Sunday, March 11, 2012 13:13:58 Jacob Carlborg wrote:
> On 2012-03-10 18:08, Jonathan M Davis wrote:
> > I honestly don't think that Walter even considered unit testing frameworks
> > when he came up with the design. He built unit tests into the language.
> > So,
> > from his point of view, why would you need a unit testing framework? He
> > probably didn't even consider it.
>
> I don't think he considered unit testing frameworks either.
>
> > And if you really want to do your own unit testing framework, maybe you
> > should just create your own custom assertion functions which throw
> > something other than AssertError - though if they don't throw Errors,
> > then any unittest blocks with a catch(Exception() {} in them may not work
> > properly, so that's not necessarily all that great a solution either,
> > depending.
> >
> > - Jonathan M Davis
>
> Yeah, exactly. And it feels a bit stupid to duplicate the assert
> statement just to throw something that isn't an AssertError.
Not to say that it's what you have to do, but I _would_ point out that all of
the unit testing frameworks that I've seen in other langages _do_ create their
own custom assert statements, so that wouldn't be abnormal at all. Now, in
C++, assert doesn't throw anything (I don't remember if it does in Java or
not), and there's no built-in unit testing framework using assert, so it's not
as weird to use your own as it would be in D, but it's still not uncommon in
unit testing frameworks to define a set of custom assertion functions
specfically for unit testing.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list