Home | History | Annotate | Download | only in triangle
      1 package test.triangle;
      2 
      3 import org.testng.annotations.Parameters;
      4 import org.testng.annotations.Test;
      5 
      6 /**
      7  * this test checks the CountCalls's static counter to see if we got the
      8  * expected number of calls
      9  */
     10 public class CheckCount {
     11 
     12   @Test(parameters = { "expected-calls" })
     13   public void testCheckCountDeprecated(String expectedCalls){
     14     try {
     15 
     16       //      System.out.println("\n\ntestCheckCount time = " + System.currentTimeMillis());
     17       int i = Integer.valueOf(expectedCalls);
     18       int numCalls =  CountCalls.getNumCalls();
     19       assert (numCalls == i)  : "Count calls expected " + i + " but got " + numCalls;
     20     }
     21     catch (NumberFormatException nfe) {
     22       assert false : "CountCalls needs an expected-calls numeric parameter";
     23     }
     24   }
     25 
     26   @Parameters({ "expected-calls" })
     27   @Test
     28   public void testCheckCount(String expectedCalls){
     29     try {
     30 
     31       //      System.out.println("\n\ntestCheckCount time = " + System.currentTimeMillis());
     32       int i = Integer.valueOf(expectedCalls);
     33       int numCalls =  CountCalls.getNumCalls();
     34       assert (numCalls == i)  : "Count calls expected " + i + " but got " + numCalls;
     35     }
     36     catch (NumberFormatException nfe) {
     37       assert false : "CountCalls needs an expected-calls numeric parameter";
     38     }
     39   }
     40 
     41 }