Improving unit tests
Janderson
ask at me.com
Sun Nov 9 00:43:19 PST 2008
Don wrote:
> assert() could have different behaviour depending on
> whether it's in the unit testing phase, or not.
I agree. I also think that you may want different types of asserts such as:
assert() //Standard
unitchecked_assert( ) //Only happens for unit checks. I've found this
very useful in my projects.
soft_assert( ) //Doesn't stop program function but reports error. Users
can of course override this to send the output elsewhere. It can also
be turned on for verbose check where it will stop in the debugger when
it occurs. Also this would not show up in unit checks. Why? Because
the unit checks should be able to pass invalid data into functions (ie a
missing file name) and have the program continue. Note softasserts are
similar but not the same as exceptions.
More information about the Digitalmars-d
mailing list