Clover coverage report - jMock - 1.0-beta1
Coverage timestamp: Sat Nov 29 2003 19:35:59 GMT
file stats: LOC: 72   Methods: 7
NCLOC: 49   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AbstractExpectation.java 100% 100% 100% 100%
coverage
 1   
 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
 2   
 package org.jmock.expectation;
 3   
 
 4   
 abstract public class AbstractExpectation implements Verifiable, Expectation {
 5   
     protected boolean myFailureModeIsImmediate = true;
 6   
     protected String myName;
 7   
 
 8   
     private boolean myHasExpectations = false;
 9   
 
 10  522
     public AbstractExpectation(String name) {
 11  522
         myName = name;
 12   
     }
 13   
 
 14  70
     protected void assertEquals(
 15   
             String msg,
 16   
             int expectedValue,
 17   
             int actualValue) {
 18  70
         assertEquals(msg, new Integer(expectedValue), new Integer(actualValue));
 19   
     }
 20   
 
 21   
     /**
 22   
      * Due to junit Assert being a Singleton implemented with static methods, and java's
 23   
      * unfortunate implementation of class methods (e.g. no late binding) it is
 24   
      * necessary to re-implement this method here instead of over-riding failNotEquals
 25   
      */
 26   
 
 27  320
     protected void assertEquals(
 28   
             String msg,
 29   
             Object expectedValue,
 30   
             Object actualValue) {
 31  320
         if (!myHasExpectations)
 32  84
             return;
 33   
 
 34  236
         if (expectedValue == null && actualValue == null)
 35  4
             return;
 36   
 
 37  232
         if (expectedValue != null && expectedValue.equals(actualValue))
 38  188
             return;
 39   
 
 40  44
         junit.framework.Assert.fail(
 41   
                 myName
 42   
                 + " "
 43   
                 + msg
 44   
                 + "\nExpected: "
 45   
                 + expectedValue
 46   
                 + "\nReceived: "
 47   
                 + actualValue);
 48   
 
 49   
     }
 50   
 
 51   
     abstract public void clearActual();
 52   
 
 53  58
     public boolean hasExpectations() {
 54  58
         return myHasExpectations;
 55   
     }
 56   
 
 57  34
     public void setFailOnVerify() {
 58  34
         myFailureModeIsImmediate = false;
 59   
     }
 60   
 
 61  298
     protected void setHasExpectations() {
 62  298
         clearActual();
 63  298
         myHasExpectations = true;
 64   
     }
 65   
 
 66  294
     protected boolean shouldCheckImmediately() {
 67  294
         return myFailureModeIsImmediate && myHasExpectations;
 68   
     }
 69   
 
 70   
     public abstract void verify();
 71   
 }
 72