01: package test.junit;
02:
03: import junit.framework.TestCase;
04:
05: /**
06: * Test that the correct number of constructors is called
07: *
08: * Created on Aug 9, 2005
09: * @author cbeust
10: */
11: public class JUnitConstructorTest extends TestCase {
12: private static int m_constructorCount = 0;
13: private static int m_createCount = 0;
14: private static int m_queryCount = 0;
15:
16: public JUnitConstructorTest(/*String string */) {
17: // super(string);
18: // setName(string);
19: ppp("CONSTRUCTING");
20: m_constructorCount++;
21: }
22:
23: // public void test1() {
24: // ppp("TEST1");
25: // }
26: //
27: // public void test2() {
28: // ppp("TEST2");
29: // }
30:
31: public void testCreate() {
32: ppp("TEST_CREATE");
33: m_createCount++;
34: }
35:
36: public void testQuery() {
37: ppp("TEST_QUERY");
38: m_queryCount++;
39: }
40:
41: @Override
42: public void tearDown() {
43: assertEquals(3, m_constructorCount);
44: assertTrue((1 == m_createCount && 0 == m_queryCount)
45: || (0 == m_createCount && 1 == m_queryCount));
46: }
47:
48: private static void ppp(String s) {
49: System.out.println("[JUnitHierarchyTest] " + s);
50: }
51: }
|