Clover coverage report - jMock - 1.0-beta1
Coverage timestamp: Sat Nov 29 2003 19:35:59 GMT
file stats: LOC: 103   Methods: 9
NCLOC: 89   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
AssertMo.java 50% 76.2% 77.8% 73.5%
coverage coverage
 1   
 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
 2   
 package org.jmock.expectation;
 3   
 
 4   
 import junit.framework.Assert;
 5   
 import junit.framework.AssertionFailedError;
 6   
 
 7   
 public class AssertMo extends Assert {
 8   
 
 9  6
     protected AssertMo() {
 10  6
         super();
 11   
     }
 12   
 
 13  10
     public static void assertEquals(
 14   
             String description,
 15   
             Object[] expectedArray,
 16   
             Object[] actualArray) {
 17  10
         assertEquals(
 18   
                 description + " (different lengths)",
 19   
                 expectedArray.length,
 20   
                 actualArray.length);
 21  8
         for (int i = 0; i < expectedArray.length; i++) {
 22  8
             assertEquals(
 23   
                     description + " (element " + i + ")",
 24   
                     expectedArray[i],
 25   
                     actualArray[i]);
 26   
         }
 27   
     }
 28   
 
 29  4
     public static void assertExcludes(
 30   
             String description,
 31   
             String excludeString,
 32   
             String targetString) {
 33  4
         assertTrue(
 34   
                 description
 35   
                 + "\nExclude String: "
 36   
                 + excludeString
 37   
                 + "\n Target String: "
 38   
                 + targetString,
 39   
                 targetString.indexOf(excludeString) == -1);
 40   
     }
 41   
 
 42  42
     public static void assertIncludes(
 43   
             String description,
 44   
             String includeString,
 45   
             String targetString) {
 46  42
         assertTrue(
 47   
                 description
 48   
                 + "\nInclude String: "
 49   
                 + includeString
 50   
                 + "\n Target String: "
 51   
                 + targetString,
 52   
                 targetString.indexOf(includeString) != -1);
 53   
     }
 54   
 
 55  4
     public static void assertStartsWith(
 56   
             String description,
 57   
             String startString,
 58   
             String targetString) {
 59  4
         assertTrue(
 60   
                 description
 61   
                 + "\n Start String: "
 62   
                 + startString
 63   
                 + "\nTarget String: "
 64   
                 + targetString,
 65   
                 targetString.startsWith(startString));
 66   
     }
 67   
 
 68  32
     public static void assertVerifyFails(Verifiable aVerifiable) {
 69  32
         boolean threwException = false;
 70  32
         try {
 71  32
             aVerifiable.verify();
 72   
         } catch (AssertionFailedError ex) {
 73  32
             threwException = true;
 74   
         }
 75   
 
 76  32
         assertTrue("Should not have verified", threwException);
 77   
     }
 78   
 
 79  0
     static protected void failNotEquals(
 80   
             String message,
 81   
             Object expected,
 82   
             Object actual) {
 83  0
         String formatted = "";
 84  0
         if (message != null)
 85  0
             formatted = message + " ";
 86  0
         fail(
 87   
                 formatted + "\nExpected:<" + expected + ">\nReceived:<" + actual + ">");
 88   
     }
 89   
 
 90  0
     public static void notImplemented(String mockName) {
 91  0
         throw new NotImplementedException("Not Implemented in " + mockName);
 92   
     }
 93   
 
 94  4
     public static void assertFails(String message, Runnable runnable) {
 95  4
         try {
 96  4
             runnable.run();
 97   
         } catch (AssertionFailedError expected) {
 98  2
             return;
 99   
         }
 100  2
         fail(message);
 101   
     }
 102   
 }
 103