Home > The Unit Test Framework > Testing tools >
PrevNext

The UTF testing tools or tester's toolbox for all occasions

Table of Contents

Output testing tool
Custom predicate support
Floating-point comparison algorithms
Reference

Introduction

The UTF's supplies a toolbox of testing tools to ease creation and maintenance of test programs and provide a uniform error reporting mechanism. The toolbox supplied in most part in a form of macro and function declarations. While the functions can be called directly, the usual way to use testing tools is via convenience macros. All macros arguments are calculated once, so it's safe to pass complex expressions in their place. All tools automatically supply an error location: a file name and a line number. The testing tools are intended for unit test code rather than library or production code, where throwing exceptions, using assert(), boost::concept_check or BOOST_STATIC_ASSERT() may be more suitable ways to detect and report errors. For list of all supplied testing tools and usage examples see the reference.

Testing tools flavors

All the tools are supplied in three flavors(levels): WARN, CHECK and REQUIRE. For example: BOOST_WARN_EQUAL, BOOST_CHECK_EQUAL, BOOST_REQUIRE_EQUAL. If an assertion designated by the tool passes, confirmation message can be printed in log output[6]. If an assertion designated by the tool failed, depending on the level following will happened[7]:

Table 5. Testing tools levels differences

Level Test log content Errors counter Test execution
WARN warning in <test case name>: condition <assertion description> is not satisfied not affected continues
CHECK error in <test case name>: test <assertion description> failed increased continues
REQUIRE fatal error in <test case name>: critical test <assertion description> failed increased aborts

Regularly you should use CHECK level tools to implement your assertions. You can use WARN level tools to validate aspects less important then correctness: performance, portability, usability etc. You should use REQUIRE level tools only if continuation of the test case doesn't make sense if this assertions fails.



[6] to manage what messages appear in the test log stream set the proper log level

[7] in some cases log message can be slightly different to reflect failed tool specifics


PrevUpHomeNext