Here is an example test for our customer library written in CppUnit. We will split it into several snippets.
The following code block prepares us to use the constructs from the CppUnit library:
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TestCase.h>
#include <cppunit/TestFixture.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TextTestRunner.h>
#include "customer/customer.h"
using namespace CppUnit;
using namespace std;
Next, we must define the test class and implement the method that will execute our test case. After that, we must register the class so that we can use it in our test runner:
class TestBasicResponses : public CppUnit::TestFixture...