CCUnit  2.1
A C Unit Testing Library
 全て データ構造 ファイル 関数 変数 型定義 列挙型 列挙型の値 マクロ定義 グループ ページ
変数
構造体 CCUnitTestCase

Wraps a test case with setUp and tearDown function. [詳細]

#include <CCUnitTestCase.h>

CCUnitTestCaseのコラボレーション図
Collaboration graph

変数

CCUnitTest test
 super class
const char * name
 test case name
CCUnitTestFuncsetUpBeforeClass
 setUp for a case
CCUnitTestFunctearDownAfterClass
 tearDown for a case
CCUnitTestFuncsetUp
 setUp for each tests
CCUnitTestFunctearDown
 tearDown for each tests
CCUnitList testFuncs
 test functions

説明

Wraps a test case with setUp and tearDown function.

A TestCase is used to provide a common environment for a set of test cases.

To define a test case, do the following:

Each test runs in its own case so there can be no side effects among test runs. Here is an example:

static int value1, value2;
void setUp_MathTest ()
{
value1 = 2;
value2 = 3;
}
...
CCUnitTestCase* MathTest_newTestCase ()
{
return ccunit_newTestCase ("MathTest", setUp_MathTest, NULL);
}

For each test implement a function which interacts with the case. Verify the expected results with assertions specified by calling CCUNIT_ASSERT on the expression you want to test:

void testAdd ()
{
int result = value1 + value2;
CCUNIT_ASSERT (result == 5);
}
...
void MathTest_newTestCase_testAdd ()
{
return ccunit_newTestCase ("testAdd", "add test", testAdd);
}

The tests to be run can be collected into a TestSuite.

CCUintTestSuite* MathTest_suite ()
{
CCUnitTestSuite* suite = ccunit_newTestSuite ("MathTest");
CCUnitTestCase* tcase = MathTest_newTestCase ();
ccunit_addTestCase (suite, tcase);
ccunit_addTestCase (tcase, MathTest_newTestCase_testAdd ());
ccunit_addTestCase (tcase, MathTest_newTestCase_testDivZero ())
return suite;
}

Once the functions are defined you can run them. To do this, use a TestRunner.

CCUnitTestSuite *suite = MathTest_suite ();
runner->run (runner, suite);

A command line tool have been created for convenience. It is located in src/tools/ccunit_makeSuite.c.

参照:
CCUnitTestResult, CCUnitTestCase, CCUnitTestSuite, MakeSuite,

構造体

const char* CCUnitTestCase::name

test case name

参照元 ccunit_newTestCase(), と destroy().

CCUnitTestFunc* CCUnitTestCase::setUp

setUp for each tests

参照元 ccunit_addTestFunc(), destroy(), と run().

CCUnitTestFunc* CCUnitTestCase::setUpBeforeClass

setUp for a case

参照元 ccunit_addTestFunc(), destroy(), と run().

CCUnitTestFunc* CCUnitTestCase::tearDown

tearDown for each tests

参照元 ccunit_addTestFunc(), destroy(), と run().

CCUnitTestFunc* CCUnitTestCase::tearDownAfterClass

tearDown for a case

参照元 ccunit_addTestFunc(), destroy(), と run().

CCUnitTest CCUnitTestCase::test
CCUnitList CCUnitTestCase::testFuncs

test functions

参照元 ccunit_addTestFunc(), ccunit_newTestCase(), destroy(), と run().


この構造体の説明は次のファイルから生成されました:
SourceForge.jp hosts this site. Send comments to: CCUnit Developer