#include <TestCase.h>
Inheritance diagram for cppunit::TestCase::
Public Methods | |
TestCase (const char *name) | |
コンストラクタ。. More... | |
virtual | ~TestCase () |
デストラクタ。. More... | |
virtual void | run (TestResult *result) |
テストを実行し、結果を集める。 Run the test, collecting results. More... | |
virtual int | countTestCases () const |
テストケースの個数を返す。 Return the number of test cases invoked by run(). More... | |
virtual const char * | getName () const |
テストの名前を返す。 Returns the test name. More... | |
virtual cu_String | toString () const |
文字列に変換する。 Description of the test, for diagnostic output. More... | |
virtual void | setUp () |
テストを初期化する。 A hook for fixture set up. More... | |
virtual void | tearDown () |
テストの後片付けをする。 A hook for fixture tear down. More... | |
Protected Methods | |
void | startTest (TestResult *result) |
TestResult にテストの開始を通知する。. More... | |
void | endTest (TestResult *result) |
TestResult にテストの終了を通知する。. More... | |
void | runBare () |
実際にテストを実行する。. More... | |
virtual void | runTest ()=0 |
テストの内容を定義する。 All the work for runTest is deferred to subclasses. More... | |
void | addFailure (const cu_String &msg, const char *file, long line) |
テストの失敗を追加する。. More... | |
void | addError (const cu_String &msg, const char *file, long line) |
エラーを追加する。. More... | |
bool | assertEqualsImpl (int expected, int actual, const char *file, long line) |
bool | assertEqualsImpl (long expected, long actual, const char *file, long line) |
bool | assertEqualsImpl (double expected, double actual, const char *file, long line, double delta=0) |
bool | assertEqualsImpl (const char *expected, const char *actual, const char *file, long line) |
template<class Ch, class Tr, class Alloc> bool | assertEqualsImpl (const char *expected, const std::basic_string< Ch, Tr, Alloc > &actual, const char *file, long line) |
template<class Ch, class Tr, class Alloc> bool | assertEqualsImpl (const std::basic_string< Ch, Tr, Alloc > &expected, const char *actual, const char *file, long line) |
template<class Ch, class Tr, class Alloc> bool | assertEqualsImpl (const std::basic_string< Ch, Tr, Alloc > &expected, const std::basic_string< Ch, Tr, Alloc > &actual, const char *file, long line) |
Static Protected Methods | |
bool | equals (double x1, double x2, double delta=0) |
bool | equals (const char *s1, const char *s2) |
cu_String | notEqualsMessage (int expected, int actual) |
cu_String | notEqualsMessage (long expected, long actual) |
cu_String | notEqualsMessage (double expected, double actual) |
cu_String | notEqualsMessage (const char *expected, const char *actual) |
This class is used to implement a simple test case: define a subclass that overrides the runTest method.
A test case defines the fixture to run multiple tests. To define a test case, do the following:
class MathTest : public TestCase { protected: int m_value1; int m_value2; public: explicit MathTest(const char* name) : TestCase(name) {} virtual void setUp() { m_value1 = 2; m_value2 = 3; } };
For each test implement a method which interacts with the fixture.
Verify the expected results with assertions specified by calling
TEST_ASSERT
on the expression you want to test:
public: void testAdd() { int result = m_value1 + m_value2; TEST_ASSERT(result == 5); }
Once the methods are defined you can run them. To do this, use a TestCaller.
Test* test = new TEST_CALLER(MathTest, testAdd); TestResult result; test->run(&result);
The tests to be run can be collected into a TestSuite.
public: static Test* MathTest::suite() { TestSuite* suite = new TestSuite("MathTest"); suite->addTest(new TEST_CALLER(MathTest, testAdd)); suite->addTest(new TEST_CALLER(MathTest, testDivideByZero)); return suite; }
|
コンストラクタ。.
|
|
デストラクタ。.
|
|
テストを実行し、結果を集める。
Reimplemented from cppunit::Test. |
|
テストケースの個数を返す。
The base unit of testing is the class TestCase. Reimplemented from cppunit::Test. |
|
テストの名前を返す。 Each test has a name. This name may be used to find the test in a suite of tests. Reimplemented from cppunit::Test. |
|
文字列に変換する。
The test description will typically include the test name, but may have additional description. Reimplemented from cppunit::Test. |
|
テストを初期化する。
|
|
テストの後片付けをする。
|
|
TestResult にテストの開始を通知する。.
|
|
TestResult にテストの終了を通知する。.
|
|
実際にテストを実行する。.
|
|
テストの内容を定義する。
|
|
テストの失敗を追加する。.
|
|
エラーを追加する。.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|