01: package org.hanseltest;
02:
03: import junit.framework.TestCase;
04: import junit.framework.TestResult;
05:
06: import org.hansel.CoverageDecorator;
07: import org.hansel.Util;
08:
09: /**
10: * Test class literals. This requires a seperate test, because javac generates
11: * a synthetic method to get the class reference.
12: * @author Niklas Mehner
13: */
14: public class TestClassLiteral extends TestCase {
15: /** Class to be covered. */
16: private static final Class[] COVERED = { CoverClassLiteral.class };
17:
18: /**
19: * Creates a new test.
20: * @param name Name of the test.
21: */
22: public TestClassLiteral(String name) {
23: super (name);
24: }
25:
26: /**
27: * Test full coverage.
28: */
29: public void testFullCoverage() {
30: CoverageDecorator cd = new CoverageDecorator(
31: FullCoverage.class, COVERED);
32:
33: TestResult result = new TestResult();
34: cd.run(result);
35:
36: Util.dumpResult(result);
37: // No failures
38: assertEquals(0, result.failureCount());
39:
40: // No errors
41: assertEquals(0, result.errorCount());
42: }
43:
44: /** Fully cover the class. */
45: public static class FullCoverage extends TestCase {
46: /**
47: * Creates a new test.
48: * @param name Name of the test.
49: */
50: public FullCoverage(String name) {
51: super (name);
52: }
53:
54: /** Fully cover the class. */
55: public void testAll() {
56: CoverClassLiteral ccl = new CoverClassLiteral();
57: assertEquals("org.hanseltest.CoverClassLiteral", ccl
58: .getClassName());
59: }
60: }
61:
62: }
|