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