¤¦¤Ê¿¿µ¶ÃͤòÅϤ·¤Þ¤¹¡£</li>
</ol>
-Î㤨¤Ð¡¢Æó¤Ä¤ÎÉûÁÇ¿ô¤Î¹ç·×¤¬¡¢Æó¤Ä¤ÎÉûÁÇ¿ô¤ÎÃͤιç·×¤Ç¤¢¤ë¤³
-¤È¤ò¥Æ¥¹¥È¤¹¤ë¤È¤·¤Þ¤¹¡£
+Î㤨¤Ð¡¢Æó¤Ä¤ÎÊ£ÁÇ¿ô¤Î¹ç·×¤¬¡¢Æó¤Ä¤ÎÊ£ÁÇ¿ô¤ÎÃͤò²Ã»»¤·¤¿¤â¤Î
+¤Ç¤¢¤ë¤³¤È¤ò¥Æ¥¹¥È¤¹¤ë¤È¤·¤Þ¤¹¡£
@code
void test_complex_add ()
}
@endcode
-That was a very simple test. Ordinarily, you'll have many
-little test cases that you'll want to run on the same set of
-objects. To do this, use a fixture.
+¤³¤ì¤ÏÂçÊÑñ½ã¤Ê¥Æ¥¹¥È¤Ç¤¹¡£
+Ä̾Ʊ¤¸¥Ç¡¼¥¿¤Î¥»¥Ã¥È¤ÇÁö¤é¤»¤ë¤¿¤á¤Ë¡¢
+¤¿¤¯¤µ¤ó¤Î¾®¤µ¤Ê¥Æ¥¹¥È¥±¡¼¥¹¤òºî¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Ç¤·¤ç¤¦¡£
+¤½¤¦¤¹¤ë¤Ë¤Ï¥Õ¥£¥¯¥¹¥Á¥ã¡ÊÈ÷Éʡˤò»È¤¤¤Þ¤¹¡£
-@section fixture Fixture
+@section fixture_ja ¥Õ¥£¥¯¥¹¥Á¥ã
-What if you have two or more tests that operate on the same
-similar set of objects?
+¤â¤·Æó¤Ä°Ê¾å¤Î¥Æ¥¹¥È¤¬¤¢¤ë¤Ê¤é¡¢
+Ʊ¤¸Îà»÷¤Î¥Ç¡¼¥¿¤Î¥»¥Ã¥È¤ÇÁàºî¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
-Tests need to run against the background of a known set of
-objects. This set of objects is called a test fixture. When
-you are writing tests you will often find that you spend
-more time writing the code to set up the fixture than you do
-in actually testing values.
+¥Æ¥¹¥È¤Ï¼þÃΤΥǡ¼¥¿¤Î¥»¥Ã¥È¤òÇطʤˤ·¤Æ¼Â¹Ô¤µ¤ì¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
+¤³¤Î¥Ç¡¼¥¿¤Î¥»¥Ã¥È¤ò¥Õ¥£¥¯¥¹¥Á¥ã¤È¸Æ¤Ö¤³¤È¤Ë¤·¤Þ¤¹¡£
+¥Æ¥¹¥È¤ò½ñ¤¤¤Æ¤¤¤ë¤È¡¢
+¼ÂºÝ¤Î¥Æ¥¹¥È¤¹¤ëÃͤò¥Õ¥£¥¯¥¹¥Á¥ã¤Ë¥»¥Ã¥È¥¢¥Ã¥×¤¹¤ë¥³¡¼¥É¤ò½ñ¤¯Êý¤Ë¡¢
+¤â¤Ã¤È»þ´Ö¤ò¤«¤±¤Æ¤¤¤ë¤³¤È¤Ëµ¤¤Å¤¯¤³¤È¤¬¤è¤¯¤¢¤ê¤Þ¤¹¡£
-Often, you will be able to use the same fixture for sevral
-different tests. Each case will send slightly different
-messages or parameteres to the fixture and will check for
-different results.
-
-When you have a common fixture, here is what you do:
+¤â¤·¶¦Ä̤¹¤ë¥Õ¥£¥¯¥¹¥Á¥ã¤¬¤¢¤ì¤Ð¡¢¤³¤ó¤Ê¤Õ¤¦¤Ë¤¹¤ë¤³¤È¤Ë¤Ê¤ê
+¤Þ¤¹¡£
<ol>
-<li>Create a @link CCUnitTestCase TestCase @endlink object</li>
-<li>Add an global variable for each part of the fixture</li>
-<li>Write <code>setUp()</code> function to initialize the valiables</li>
-<li>Write <code>tearDown()</code> to release any permanent
- resources you allocated in <code>setUp</code></li>
-<li>Create a @link CCUnitTestFixture TestFixture @endlink object</li>
-<li>Add test case objects to fixture object</li>
+<li>@link CCUnitTestCase CCUnitTestCase @endlink
+¹½Â¤ÂΤ˥á¥â¥ê¤ò³ä¤êÅö¤Æ¤Þ¤¹
+¡Ê°Ê¹ß¡¢¹½Â¤ÂΤ˳ä¤êÅö¤Æ¤¿¥á¥â¥ê¤ò¡¢¥ª¥Ö¥¸¥§¥¯¥È¤È¸Æ¤Ö¤³¤È¤Ë¤·¤Þ¤¹¡Ë
+</li>
+<li>¥Õ¥£¥¯¥¹¥Á¥ã¤Î¤½¤ì¤¾¤ì¤ÎÉôʬ¤ËÂç°èÊÑ¿ô¤òÄɲä·¤Þ¤¹</li>
+<li><code>setUp()</code> ´Ø¿ô¤ò½ñ¤¤¤ÆÊÑ¿ô¤ò½é´ü²½¤·¤Þ¤¹</li>
+<li><code>tearDown()</code> ´Ø¿ô¤ò½ñ¤¤¤Æ<code>setUp</code>
+¤Ç³ä¤êÅö¤Æ¤¿±Ê³Ū¥ê¥½¡¼¥¹¤ò²òÊü¤·¤Þ¤¹</li>
+<li>@link CCUnitTestFixture CCUnitTestFixture @endlink
+¹½Â¤ÂΤ˥á¥â¥ê¤ò³ä¤êÅö¤Æ¤Þ¤¹</li>
+<li>¥Æ¥¹¥È¥±¡¼¥¹¥ª¥Ö¥¸¥§¥¯¥È¤ò¥Õ¥£¥¯¥¹¥Á¥ã¥ª¥Ö¥¸¥§¥¯¥È¤ËÄɲä·¤Þ¤¹</li>
</ol>
-For example, to write several test cases, first create a
-fixture:
+Î㤨¤Ð¡¢¤¤¤¯¤Ä¤«¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¯¾ì¹ç¡¢
+ºÇ½é¤Ë¥Õ¥£¥¯¥¹¥Á¥ã¤òºîÀ®¤·¤Þ¤·¤ç¤¦¡£
@code
-//** TEST CASE: complex number test *\/
+//** TEST CASE: Ê£ÁÇ¿ô¥é¥¤¥Ö¥é¥ê¥Æ¥¹¥È *\/
#include "complex.h"
CCUNIT_NEWTESTFUNC(tearDown_ComplexTest));
@endcode
-Once you have the Fixture in place, you can write as complex
-Test Cases as you'd like.
+°ìÅÙ·è¤Þ¤Ã¤¿¤È¤³¤í¤Ë¥Õ¥£¥¯¥¹¥Á¥ã¤ò½ñ¤¤¤Æ¤·¤Þ¤¨¤Ð¡¢
+¤¢¤Ê¤¿¤¬¹¥¤¤Ê¤è¤¦¤ËÊ£ÁÇ¿ô¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¯¤³¤È¤¬¤Ç¤¤ë¤Ç¤·¤ç¤¦¡£
-@section test_case Test Case
+@section test_case_ja ¥Æ¥¹¥È¥±¡¼¥¹
-How do you write and invoke an individual test case when you
-have a Fixture?
+¥Õ¥£¥¯¥¹¥Á¥ã¤ò°ì¤Ä½ñ¤¤¤¿¤È¤·¤Æ¡¢
+¤É¤¦¤ä¤Ã¤Æ¸Ä¡¹¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò½ñ¤¤¤Æ¼Â¹Ô¤¹¤ì¤ÐÎɤ¤¤Ç¤·¤ç¤¦¤«¡£
-For example, to test the equality of two complex number,
-write:
+Î㤨¤Ð¡¢Æó¤Ä¤ÎÊ£ÁÇ¿ô¤¬Åù¤·¤¤¡Ê¤Þ¤¿¤ÏÅù¤·¤¯¤Ê¤¤¡Ë¤³¤È¤ò¥Æ¥¹¥È¤¹¤ë¤Ë¤Ï¡¢
+¼¡¤Î¤è¤¦¤Ë½ñ¤¤Þ¤¹¡£
@code
void test_complex_equals ()
ccunit_addNewTestCase (fixture,
"test_complex_equals",
- "complex equals test",
+ "Ê£ÁÇ¿ôÅùÃͥƥ¹¥È",
test_complex_equals);
ccunit_addNewTestCase (fixture,
"test_complex_add",
- "complex add test",
+ "Ê£ÁÇ¿ô²Ã»»¥Æ¥¹¥È",
test_complex_add);
@endcode
-One may create and run objects for each test case like this:
+°ì¤Ä¤Ë¤Ï¼¡¤Î¤è¤¦¤Ë¡¢
+¥Õ¥£¥¯¥¹¥Á¥ã¤òºîÀ®¤·¤Æ¤½¤ì¤¾¤ì¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò¼Â¹Ô¤µ¤»¤ë¤³¤È
+¤¬¤Ç¤¤Þ¤¹¡£
@code
CCUnitTestResult* result;
result = ccunit_runTestFixture (fixture);
@endcode
-When the test fixture is run, that specific test functions
-will be run. This is not a useful thing to do, however, as
-no diagnostics will be displayed. One will normally use a
-@link ExecutingTest TestRunner @endlink (see below) to
-display the results.
-
-Once you have several tests, organize them into a suite.
+¥Æ¥¹¥È¥Õ¥£¥¯¥¹¥Á¥ã¤¬¼Â¹Ô¤µ¤ì¤ë¤È¡¢
+ÆÃÄê¤Î¥Æ¥¹¥È´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£
+¤³¤ì¤Ï¤¢¤Þ¤êÊØÍø¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡¢
+¤Ê¤¼¤Ê¤é¡¢¿ÇÃǤ¬É½¼¨¤µ¤ì¤Ê¤¤¤«¤é¤Ç¤¹¡£
+Ä̾ï¤Ï @link ExecutingTest TestRunner @endlink (¸å½Ò)
+¤Ç·ë²Ì¤òɽ¼¨¤·¤Þ¤¹¡£
-@section suite Suite
+°ìÅÙ¤¤¤¯¤Ä¤«¤Î¥Æ¥¹¥È¤òºî¤Ã¤¿¤é¡¢
+¤½¤ì¤é¤ò¥¹¥¤¡¼¥È¤ËÀ°Íý¤·¤Þ¤¹¡£
-How do you set up your tests so that you can run them all at once?
+@section suite_ja ¥¹¥¤¡¼¥È
-%CCUnit provides a @link CCUnitTestSuite TestSuite @endlink
-module that runs any number of TestCases together.
+¤É¤Î¤è¤¦¤Ë¤·¤Æ¡¢°ìÅ٤˥ƥ¹¥È¤ò¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¤è¤¦¡¢
+½àÈ÷¤·¤·¤¿¤é¤¤¤¤¤Ç¤·¤ç¤¦¤«¡©
-You saw, above, how to run test fixture.
+CCUnit ¤Ï¤¤¤¯¤Ä¤â¤Î @link CCUnitTestCase TestCases @endlink
+¤ò°ì½ï¤Ë¼Â¹Ô¤¹¤ë
+@link CCUnitTestSuite TestSuite @endlink ¥â¥¸¥å¡¼¥ë¤òÄ󶡤·¤Þ¤¹¡£
-To create a suite of two or more tests, you do the following:
+¥Æ¥¹¥È¥Õ¥£¥¯¥¹¥Á¥ã¤ò¼Â¹Ô¤¹¤ëÊýË¡¤Ï¾å½Ò¤·¤Þ¤·¤¿¡£
+Æó¤Ä°Ê¾å¤Î¥Æ¥¹¥È¤ò´Þ¤à°ì¤Ä¤Î¥¹¥¤¡¼¥È¤òºî¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
@code
CCUnitTestSuite* suite;
CCUnitTestFixture* fixture;
CCUnitTestResult* result;
-suite = ccunit_newTestSuite ("Complex test suite");
-fixture = ccunit_newTestFixture ("Complex Tests",
+suite = ccunit_newTestSuite ("Ê£ÁÇ¿ô¥Æ¥¹¥È¥¹¥¤¡¼¥È");
+fixture = ccunit_newTestFixture ("Ê£ÁÇ¿ô¥Æ¥¹¥È",
CCUNIT_NEWTESTFUNC(setUp_complex_test),
CCUNIT_NEWTESTFUNC(tearDown_complex_test));
-ccunit_addNewTestCase (fixture, "test_complex_equals", "complex equals test",
+ccunit_addNewTestCase (fixture, "test_complex_equals", "Ê£ÁÇ¿ôÅùÃͥƥ¹¥È",
test_complex_equals);
-ccunit_addNewTestCase (fixture, "test_complex_add", "complex add test",
+ccunit_addNewTestCase (fixture, "test_complex_add", "Ê£ÁÇ¿ô²Ã»»¥Æ¥¹¥È",
test_complex_add);
-ccunit_addNewTestCase (fixture, "test_complex_sub", "complex sub test",
+ccunit_addNewTestCase (fixture, "test_complex_sub", "Ê£ÁÇ¿ô¸º»»¥Æ¥¹¥È",
test_complex_sub);
ccunit_addTestFixture (suite, fixtuer);
result = ccunit_runTestSuite (suite, NULL);
@endcode
-@link CCUnitTestSuite TestSuites @endlink don't only have to
-contain @link CCUnitTestFixture TestFixtures @endlink. They
-can contain any object that implements the @link CCUnitTest
-Test @endlink interface. For example, you can create a
-@link CCUnitTestSuite TestSuite @endlink in your code and I
-can create one in mine, and we can run them together by
-creating a @link CCUnitTestSuite TestSuite @endlink that
-contains both:
+@link CCUnitTestSuite TestSuites @endlink ¤Ï
+@link CCUnitTestFixture TestFixtures @endlink
+¤ò´Þ¤à¤À¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
+
+¤½¤ì¤é¤Ï @link CCUnitTest Test @endlink
+¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤¹¤ë¤É¤ó¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤â´Þ¤á¤é¤ì¤Þ¤¹¡£
+Î㤨¤Ð¡¢¤¢¤Ê¤¿¤Ï¤¢¤Ê¤¿¤Î¥³¡¼¥É¤Ë@link CCUnitTestSuite TestSuite @endlink
+¤òºî¤ë¤³¤È¤¬¤Ç¤¡¢¤½¤·¤Æ»ä¤Ï»ä¤Î¥¹¥¤¡¼¥È¤òºî¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡¢
+¤½¤·¤Æ»äã¤ÏξÊý¤È¤â¤ò´Þ¤ó¤Ç¤¤¤ë @link CCUnitTestSuite TestSuite @endlink
+¤òºî¤Ã¤Æ°ì½ï¤Ë¸Ä¡¹¤Î¥¹¥¤¡¼¥È¤òÆ°¤«¤¹¤³¤È¤¬¤Ç¤¤ë¤Î¤Ç¤¹¡£
@code
CCUnitTestSuite* suite;
CCUnitTestResult* result;
suite = ccunit_newTestSuite ("suite");
-ccunit_addTestSuite (suite, complex_add_sub_suite ());
-ccunit_addTestSuite (suite, complex_mul_div_suite ());
+ccunit_addTestSuite (suite, complex_add_sub_suite ()); //* ¤¢¤Ê¤¿¤Î¥¹¥¤¡¼¥È *\/
+ccunit_addTestSuite (suite, complex_mul_div_suite ()); //* ¤ï¤¿¤·¤Î¥¹¥¤¡¼¥È *\/
result = ccunit_runTestSuite(suite, NULL);
@endcode
-@section test_runner TestRunner
+@section test_runner_ja TestRunner
How do you run your tests and collect their results?
<code>CCUNIT_ASSERT ()</code> which detected the failure</li>
</ul>
-@section helper_macros Helper Tool
+@section helper_macros_ja Helper Tool
As you might have noticed, implementing the fixture
<code>suite ()</code> function is a repetitive and error
},
};
-CCUnitTestSuite* complex_suite (const char* name)
+CCUnitTestSuite* ccunit_suite (const char* name)
{
if (!suite_001.name[0])
suite_001.name = name;
$
@endcode
-@section post_build_check Post-build check
+@section post_build_check_ja Post-build check
Now that we have our unit tests running, how about
integrating unit testing to our build process ?