www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Summary on unit testing situation

reply Trip Volpe <mraccident gmail.com> writes:
Trip Volpe Wrote:
 ...and if an assert fails in one test in a module, _all_ subsequent tests in
that module will be aborted, even though this makes no sense.

Actually I said this wrong. It's worse than that: after one assert failure, _all_ further execution is aborted, meaning that even unit tests in _other_ modules will be prevented from running. And you can't change this behavior, even if you override the assert failure handler, since for some reason the compiler expects the handler to throw an AssertError, and if it doesn't, a segfault may result.
Mar 23 2010
parent reply =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
On 03/23/2010 08:10 PM, Trip Volpe wrote:
 Trip Volpe Wrote:
 ...and if an assert fails in one test in a module, _all_ subsequent tests in
that module will be aborted, even though this makes no sense.

Actually I said this wrong. It's worse than that: after one assert failure, _all_ further execution is aborted, meaning that even unit tests in _other_ modules will be prevented from running. And you can't change this behavior, even if you override the assert failure handler, since for some reason the compiler expects the handler to throw an AssertError, and if it doesn't, a segfault may result.

The solution to this would be not to use asserts in unittests.
Mar 23 2010
parent reply Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> writes:
Wikipedia is usually a good place to start:

http://en.wikipedia.org/wiki/Unit_test

A couple of  the references at the end of the Wikipedia article are pretty
good, also. The Unit Testing Guidelines gives a pretty good breakdown of what
to expect (or not) from unit testing.

Paul


Pelle Månsson Wrote:

 On 03/23/2010 08:10 PM, Trip Volpe wrote:
 Trip Volpe Wrote:
 ...and if an assert fails in one test in a module, _all_ subsequent tests in
that module will be aborted, even though this makes no sense.

Actually I said this wrong. It's worse than that: after one assert failure, _all_ further execution is aborted, meaning that even unit tests in _other_ modules will be prevented from running. And you can't change this behavior, even if you override the assert failure handler, since for some reason the compiler expects the handler to throw an AssertError, and if it doesn't, a segfault may result.

The solution to this would be not to use asserts in unittests.

Mar 23 2010
parent Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> writes:
Sorry, this should have replied to the message asking for more info!

Paul

Paul D. Anderson Wrote:

 Wikipedia is usually a good place to start:
 
 http://en.wikipedia.org/wiki/Unit_test
 
 A couple of  the references at the end of the Wikipedia article are pretty
good, also. The Unit Testing Guidelines gives a pretty good breakdown of what
to expect (or not) from unit testing.
 
 Paul
 
 
 Pelle Månsson Wrote:
 
 On 03/23/2010 08:10 PM, Trip Volpe wrote:
 Trip Volpe Wrote:
 ...and if an assert fails in one test in a module, _all_ subsequent tests in
that module will be aborted, even though this makes no sense.

Actually I said this wrong. It's worse than that: after one assert failure, _all_ further execution is aborted, meaning that even unit tests in _other_ modules will be prevented from running. And you can't change this behavior, even if you override the assert failure handler, since for some reason the compiler expects the handler to throw an AssertError, and if it doesn't, a segfault may result.

The solution to this would be not to use asserts in unittests.


Mar 23 2010