Boost logo

Boost :

Subject: Re: [boost] [Boost.Test] Assertion changes in trunk? [WAS: Call for Review: Boost.Test documentation rewrite]
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-01-28 17:25:59

On 24/01/2014 23:58, Quoth Alexander Lamaison:
> Tests cases should test one, and only one, logical concept each.
> Therefore, multiple assertions in the same tests case will all be
> testing the same concept. In other words, they are, together,
> constructing a report of the failure.
> Often this is possible using only one assertion, in which case CHECK and
> REQUIRE are equivalent, but sometimes more than one
> non-mutually-exlusive assertion is needed to give the full picture.

It is most useful to have both.

I generally prefer to write most test assertions as non-exclusive, but
there are certain assertions that are best being exclusive -- most
commonly because if that assertion is false, then future assertions
and/or actions would result in crashes/exceptions that aren't interesting.

(eg. you should REQUIRE that an output collection has the correct size
[either == or >=] before trying to CHECK that individual elements have
the expected values, because if the size is wrong then the value checks
will just throw exceptions or cause UB; but if the size is right then
it's useful to display all the expected vs. actual values instead of
stopping at the first mismatch.)

Although that particular case is even better if either the framework or
custom code lets you do an == on the collection as a whole, so that you
can display expected vs. actual contents in the case of a size mismatch
as well.

Boost list run by bdawes at, gregod at, cpdaniel at, john at