Unit tests and assertions (was: [Exceptional C++ Style] Item 18 - Virtuality)

Terje Slettebø tslettebo at broadpark.no
Sun Jan 9 07:59:56 EST 2005


>From: "Kevlin Henney" <kevlin at curbralan.com>

> In addition, introducing such a DbC framework is generally a waste of
> effort. Although it is based on good intentions, it is mostly ritual
> rather than time well invested. A set of unit tests will be a much
> clearer guide to the contract and the interface. Wading through an NVI
> version of a contract is more than a little tedious, especially when the
> notion of contract enforcement is based on assertions: all that
> infrastructure for something that isn't even compiled in.

Unless I misunderstand you, aren't unit tests and asserts rather
complementary to each other? The asserts checks
preconditions/postconditions/invariants, while you may use unit tests to
check that they indeed work, i.e. exercise the asserts.

Regards,

Terje




More information about the Effective-cpp mailing list