1 package org.hanseltest; 2 3 import junit.framework.TestCase; 4 import junit.framework.TestResult; 5 6 import org.hansel.CoverageDecorator; 7 8 12 public class TestException extends TestCase { 13 14 private static final Class [] COVERED = {CoverException.class}; 15 16 20 public TestException(String name) { 21 super(name); 22 } 23 24 27 public void testNoCoverage() { 28 CoverageDecorator cd = new CoverageDecorator(NoCoverage.class, 29 COVERED); 30 31 TestResult result = new TestResult(); 32 33 cd.run(result); 34 assertEquals(4, result.failureCount()); 36 assertEquals(0, result.errorCount()); 37 } 38 39 40 public void testPartCoverage1() { 41 CoverageDecorator cd = new CoverageDecorator(PartCoverage1.class, 42 COVERED); 43 44 TestResult result = new TestResult(); 45 46 cd.run(result); 47 48 assertEquals(4, result.failureCount()); 50 assertEquals(0, result.errorCount()); 51 } 52 53 54 public void testPartCoverage2() { 55 CoverageDecorator cd = new CoverageDecorator(PartCoverage2.class, 56 COVERED); 57 58 TestResult result = new TestResult(); 59 60 cd.run(result); 61 62 assertEquals(3, result.failureCount()); 64 assertEquals(0, result.errorCount()); 65 } 66 67 68 public static class NoCoverage extends TestCase { 69 73 public NoCoverage(String name) { 74 super(name); 75 } 76 77 78 public void testNothing() { 79 } 80 } 81 82 83 public static class PartCoverage1 extends TestCase { 84 88 public PartCoverage1(String name) { 89 super(name); 90 } 91 92 93 public void testPart() { 94 assertEquals(0, new CoverException().coverFinally(3, false)); 95 } 96 } 97 98 99 public static class PartCoverage2 extends TestCase { 100 104 public PartCoverage2(String name) { 105 super(name); 106 } 107 108 109 public void testPart() { 110 assertEquals(1, new CoverException().coverHandler(3)); 111 } 112 } 113 114 115 } 116 | Popular Tags |