Unit Tests
Unit tests to automatically test intended behaviour. More...
Namespaces | |
test | |
Unit tests. | |
Classes | |
class | test::TestCase |
Base class for tests. More... | |
class | test::TestSuite |
Suite of tests. More... | |
Detailed Description
Unit tests to automatically test intended behaviour.
- Introduction
- It is good practice to cover all code by unit tests. This should certainly be aimed at for all new code. Examples for such unit tests can be found in the testsuite directories and in the classes in the test namespace.
- Test case and test suite
- test::TestCase is the base class for all tests. A new test (for a class or a part of a class or a small set of classes) should be derived from test::TestCase. Several test cases can be grouped together by using test::TestSuite in the following way: int main(int argc, char** argv) {try {test::TestSuite t("Constrained Matrix Eigenvalue Problems");test::GolubExample t1; t.addTest(&t1);test::MaxwellTransmissionEVP t2; t.addTest(&t2);test::GolubExampleSum t3; t.addTest(&t3);t.run();return t.report();}catch (concepts::ExceptionBase& e) {std::cout << e << std::endl;}return 1;}
@par Template In \c doc/test.hh.template, a template for a header file of a new test and in \c doc/test.cc.template, a template for an implementation file of the test are provided. Header file template: @verbinclude test.hh.template Implementation file template: @verbinclude test.cc.template @see Chuck Allison, <a href="http://www.cuj.com/documents/s=8035/cuj0009allison1/">The Simplest Automated Unit Test Framework That Could Possibly Work</a>, C/C++ Users Journal, September 2000. @author Philipp Frauenfelder, 2004
virtual void run()
Runs the tests. Must be overwritten by the specialization.
Test case from Maxwell transmission problem with weighted regularization.
Definition: constrained.hh:122