1 package org.hanseltest; 2 3 import junit.framework.TestCase; 4 import junit.framework.TestResult; 5 6 import org.hansel.CoverageDecorator; 7 8 13 public class TestExpression extends TestCase { 14 15 private static final Class [] COVERED = {CoverExpression.class}; 16 17 21 public TestExpression(String name) { 22 super(name); 23 } 24 25 28 public void testNoCoverage() { 29 CoverageDecorator cd = new CoverageDecorator(NoCoverage.class, 30 COVERED); 31 32 TestResult result = new TestResult(); 33 34 cd.run(result); 35 36 assertEquals(5, result.failureCount()); 38 39 assertEquals(0, result.errorCount()); 41 } 42 43 47 public void testFullCoverage() { 48 CoverageDecorator cd = new CoverageDecorator(FullCoverage.class, 49 COVERED); 50 51 TestResult result = new TestResult(); 52 53 cd.run(result); 54 55 assertEquals(0, result.failureCount()); 56 57 assertEquals(0, result.errorCount()); 59 } 60 61 62 public static class NoCoverage extends TestCase { 63 64 68 public NoCoverage(String name) { 69 super(name); 70 } 71 72 75 public void testNothing() { 76 } 77 } 78 79 82 public static class FullCoverage extends TestCase { 83 84 88 public FullCoverage(String name) { 89 super(name); 90 } 91 92 95 public void testAll() { 96 CoverExpression ce = new CoverExpression(); 97 assertTrue(ce.coverNot(false)); 98 assertTrue(!ce.coverNot(true)); 99 100 assertTrue(ce.coverAnd(true, true)); 101 assertTrue(!ce.coverAnd(false, true)); 102 assertTrue(!ce.coverAnd(true, false)); 103 104 assertTrue(ce.coverOr(true, false)); 105 assertTrue(!ce.coverOr(false, false)); 106 assertTrue(ce.coverOr(false, true)); 107 108 assertTrue(ce.coverComplex(true, true, true, true)); 109 assertTrue(!ce.coverComplex(false, false, false, false)); 110 assertTrue(ce.coverComplex(true, false, true, true)); 111 assertTrue(!ce.coverComplex(true, false, true, false)); 112 } 113 } 114 115 } 116 | Popular Tags |