similar set of objects?
@~japanese
¤â¤·Æó¤Ä°Ê¾å¤Î¥Æ¥¹¥È¤¬¤¢¤ë¤Ê¤é¡¢
-Ʊ¤¸Îà»÷¤Î¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¤ÇÁàºî¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
+Ʊ¤¸Îà»÷¤Î¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¤ò»È¤¦¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
@~
@dot
digraph TestCase {
node [ fontsize=9, fontname=Helvetica ]
edge [ fontsize=9, dir=back, arrowtail=vee ]
- gv [ label="Global variables", shape=box ]
+ gv [ label="Data\n(Global variables)", shape=box ]
{ rank=same;
tc1 [ label="Test case 1" ];
tcn [ label="Test case n" ];
more time writing the code to set up the fixture than you do
in actually testing values.
@~japanese
-¥Æ¥¹¥È¤Ï¼þÃΤΥǡ¼¥¿¤Î½¸¤Þ¤ê¤òÇطʤˤ·¤Æ¼Â¹Ô¤µ¤ì¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
-¤³¤Î¥Ç¡¼¥¿¤Î¥»¥Ã¥È¤ò¥Õ¥£¥¯¥¹¥Á¥ã¤È¸Æ¤Ö¤³¤È¤Ë¤·¤Þ¤¹¡£
+¥Æ¥¹¥È¤ÏÃæ¿È¤Î¤ï¤«¤Ã¤Æ¤¤¤ë¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¤òÁ°Äó¤È¤·¤Æ¼Â¹Ô¤µ¤ì¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
+¤½¤Î¤è¤¦¤Ê¥Ç¡¼¥¿¤Î½¸¤Þ¤ê¤ò¥Õ¥£¥¯¥¹¥Á¥ã¤È¸Æ¤Ö¤³¤È¤Ë¤·¤Þ¤¹¡£
¥Æ¥¹¥È¤ò½ñ¤¤¤Æ¤¤¤ë¤È¡¢
-¼ÂºÝ¤Î¥Æ¥¹¥È¤¹¤ëÃͤò¥Õ¥£¥¯¥¹¥Á¥ã¤Ë¥»¥Ã¥È¥¢¥Ã¥×¤¹¤ë¥³¡¼¥É¤ò½ñ¤¯Êý¤Ë¡¢
+¼ÂºÝ¤Ë¥Æ¥¹¥È¤¹¤ëÃͤò¥Õ¥£¥¯¥¹¥Á¥ã¤Ë¥»¥Ã¥È¥¢¥Ã¥×¤¹¤ë¥³¡¼¥É¤ò½ñ¤¯Êý¤Ë¡¢
¤è¤ê»þ´Ö¤ò¤«¤±¤Æ¤¤¤ë¤³¤È¤Ëµ¤¤Å¤¯¤³¤È¤¬¤è¤¯¤¢¤ê¤Þ¤¹¡£
@~
different results.
@~japanese
¿¤¯¤Î¾ì¹ç¡¢¤¤¤¯¤Ä¤«¤Î°Û¤Ê¤Ã¤¿¥Æ¥¹¥È¤Î¤¿¤á¤ËƱ¤¸¥Õ¥£¥¯¥¹¥Á¥ã¤ò»È¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
-¤½¤ì¤¾¤ì¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ï¾¯¤·°Û¤Ê¤Ã¤¿¥á¥Ã¥»¡¼¥¸¡¢
-¤¢¤ë¤¤¤Ï¥Ñ¥é¥á¡¼¥¿¤ò¥Õ¥£¥¯¥¹¥Á¥ã¤ËÁ÷¤ê¡¢
+¤½¤ì¤¾¤ì¤Î¥Æ¥¹¥È¥±¡¼¥¹¤Ï¾¯¤·°Û¤Ê¤Ã¤¿Ãͤǥե£¥¯¥¹¥Á¥ã¤ò½é´ü²½¤·¡¢
°Û¤Ê¤ë·ë²Ì¤òÄ´¤Ù¤ë¤³¤È¤Ë¤Ê¤ë¤Ç¤·¤ç¤¦¡£
+¤½¤·¤Æ¥Æ¥¹¥È¤¬½ª¤ï¤Ã¤¿¤é¡¢
+¥Õ¥£¥¯¥¹¥Á¥ã¤ò¸å»ÏËö¤¹¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
+¤³¤ì¤é¤Î¥Õ¥£¥¯¥¹¥Á¥ã¤È¡¢
+¥Õ¥£¥¯¥¹¥Á¥ã¤ò½é´ü²½¡¦ÍøÍÑ¡¦¸å»ÏËö¤¹¤ë¥Æ¥¹¥È´Ø¿ô¤Î½¸¤Þ¤ê¤ò¡¢
+¥Æ¥¹¥È¥Õ¥£¥¯¥¹¥Á¥ã¤È¸Æ¤Ö¤³¤È¤Ë¤·¤Þ¤¹
+(¤â¤·¤¯¤Ïά¤·¤Æñ¤Ë¥Õ¥£¥¯¥¹¥Á¥ã¤È¸Æ¤Ó¤Þ¤¹¡£)
@~
@dot
digraph TestFixture {
node [ fontsize=9, fontname=Helvetica ]
edge [ fontsize=9, dir=back, arrowtail=vee ]
- gv [ label="Global variables", shape=box ]
- { rank=same;
- su [ label="setUp ()" ];
- tc [ label="TestCase" ];
- td [ label="tearDown ()" ];
+ rankdir=TB;
+ subgraph cluster_fixture {
+ fontsize=9;
+ label="Test Fixture";
+ gv [ label="Fixture\n(Data)", shape=box ]
+ { rank=same;
+ ssu [ label="setup_setUp" ];
+ su [ label="setUp" ];
+ tc [ label="TestCases" ];
+ td [ label="tearDown" ];
+ std [ label="setup_tearDown" ];
+ }
+ gv -> ssu [ label="initialize" ];
+ gv -> su [ label="initialize\neach test" ];
+ gv -> tc [ label="access" ];
+ gv -> td [ label="clean-up\neach test" ];
+ gv -> std [ label="clean-up" ];
}
- gv -> su [ label="initialize" ];
- gv -> tc [ label="access" ];
- gv -> td [ label="clean-up" ];
}
@enddot
@~english
When you have a common fixture, here is what you do:
@~japanese
-¤â¤·¶¦Ä̤¹¤ë¥Õ¥£¥¯¥¹¥Á¥ã¤¬¤¢¤ì¤Ð¡¢¤³¤ó¤Ê¤Õ¤¦¤Ë¤¹¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
+¤â¤·³Æ¥Æ¥¹¥È¤Ë¶¦Ä̤¹¤ë¥Ç¡¼¥¿¤¬¤¢¤ì¤Ð¡¢
+°Ê²¼¤Î¤è¤¦¤Ë¥Æ¥¹¥È¥Õ¥£¥¯¥¹¥Á¥ã¤òºî¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
@~
<ol>
<li>@~english
Add an global variable for each part of the fixture
@~japanese
- ¥Õ¥£¥¯¥¹¥Á¥ã¤Î¤½¤ì¤¾¤ì¤ÎÉôʬ¤ËÂç°èÊÑ¿ô¤òÄɲä·¤Þ¤¹
+ ¥Õ¥£¥¯¥¹¥Á¥ã¤Î¥¹¥³¡¼¥×Æâ¤ËÂç°èÊÑ¿ô¤òÄêµÁ¤·¤Þ¤¹
@~
</li>
<li>@~english
- Write <code>setUp()</code> function to initialize the valiables
+ Write @c setup_setUp(), @c setUp() function to initialize the valiables
@~japanese
- <code>setUp()</code> ´Ø¿ô¤ò½ñ¤¤¤ÆÊÑ¿ô¤ò½é´ü²½¤·¤Þ¤¹
+ ÊÑ¿ô¤ò½é´ü²½¤¹¤ë @c setup_setUp(), @c setUp() ´Ø¿ô¤ò½ñ¤¤Þ¤¹
@~
</li>
-<li>@~english
- Write <code>tearDown()</code> to release any permanent
- resources you allocated in <code>setUp</code>
- @~japanese
- <code>tearDown()</code> ´Ø¿ô¤ò½ñ¤¤¤Æ<code>setUp</code>
- ¤Ç³ä¤êÅö¤Æ¤¿±Ê³Ū¥ê¥½¡¼¥¹¤ò²òÊü¤·¤Þ¤¹
- @~
+<li>@english
+ Write @c tearDown(), @c setup_tearDown() to release any permanent
+ resources you allocated in @c setUp
+ @japanese
+ @c setup_setUp(), @c setUp() ¤Ç³ä¤êÅö¤Æ¤¿±Ê³Ū¥ê¥½¡¼¥¹¤ò²òÊü¤¹¤ë¤¿¤á¤Î
+ @c tearDown(), @c setup_tearDown() ´Ø¿ô¤ò½ñ¤¤Þ¤¹
+ @endif
</li>
<li>@~english
Create a @link CCUnitTestFixture TestFixture @endlink object
static complex_t* s10_1;
static complex_t* s1_1;
static complex_t* s11_2;
+static complex_t* sc;
+
+void setup_setUp_complex_test ()
+{
+ sc = complex_new (1, 1);
+}
+
+void setup_tearDown_complex_test ()
+{
+ complex_delete (sc);
+}
void setUp_complex_test ()
{
s10_1 = complex_new (10, 1);
s1_1 = complex_new (1, 1);
s11_2 = complex_new (11, 2);
+ complex_add (&sc, &sc, &c1_1);
}
void tearDown_complex_test ()
fixture = ccunit_newTestFixture ("complex test",
CCUNIT_NEWTESTFUNC(setUp_complex_test),
CCUNIT_NEWTESTFUNC(tearDown_complex_test));
+ ccunit_setTestFixturSetup (fixture,
+ CCUNIT_NEWTESTFUNCTION(setup_setUp_complex_test),
+ CCUNIT_NEWTESTFUNCTION(setup_tearDown_complex_test));
@endcode
@~english
@~english
One may create and run objects for each test case like this:
@~japanese
-°ì¤Ä¤Ë¤Ï¼¡¤Î¤è¤¦¤Ë¡¢
+¤½¤·¤Æ¼¡¤Î¤è¤¦¤Ë¡¢
¥Õ¥£¥¯¥¹¥Á¥ã¤òºîÀ®¤·¤Æ¤½¤ì¤¾¤ì¤Î¥Æ¥¹¥È¥±¡¼¥¹¤ò¼Â¹Ô¤µ¤»¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
@~
node [ fontsize=9, fontname=Helvetica ]
edge [ fontsize=9 ]
rankdir = LR;
- setUp -> "TestCase 1" -> tearDown;
- setUp2 [ label="setUp" ];
+ { rank=same;
+ setUp;
+ setUp2 [ label="setUp" ];
+ }
+ setup_setUp -> setUp [ weight=8 ];
+ setup_setUp -> setUp2 [ style=invis ];
+ setUp -> "TestCase 1" [ weight=8 ];
+ "TestCase 1" -> tearDown [ weight=8 ];
+ setUp2 -> "TestCase n" [ weight=8 ];
tearDown2 [ label="tearDown" ];
- setUp2 -> "TestCase n" -> tearDown2;
- tearDown -> setUp2 [ style=dotted ];
+ "TestCase n" -> tearDown2;
+ tearDown2 -> setup_tearDown;
+ tearDown -> setUp2;
}
@enddot
TestSuite -> TestSuite [ label="1..n" ];
TestFixture;
TestSuite -> TestFixture [ label="1..n" ];
+ TestFixture -> setup_setUp [ label="0..1" ];
TestFixture -> setUp [ label="0..1" ];
TestCase;
TestFixture -> TestCase [ label="1..n" ];
TestFixture -> tearDown [ label="0..1" ];
+ TestFixture -> setup_tearDown [ label="0..1" ];
}
@enddot
static complex_t* s10_1;
static complex_t* s1_1;
static complex_t* s11_2;
+static complex_t* sc;
+
+void setup_setUp_complex_test ()
+{
+ sc = complex_new (1, 1);
+}
+
+void setup_tearDown_complex_test ()
+{
+ complex_delete (sc);
+}
void setUp_complex_test ()
{
{ ccunitTypeFixture },
"complex number test",
{
+ "setup_setUp_complex_test",
+ "setup_setUp_complex_test",
+ setup_setUp_complex_test
+ },
+ {
+ "setup_tearDown_complex_test",
+ "setup_tearDown_complex_test",
+ setup_tearDown_complex_test
+ },
+ {
"setUp_complex_test",
"setUp_complex_test",
setUp_complex_test