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.probes.StringProbeFilter;
08:
09: /**
10: * Test the probe filter interface..
11: *
12: * @author Niklas Mehner
13: */
14: public class TestProbeFilter extends TestCase {
15: /** Class that should be covered by the tests. */
16: private static final Class[] COVERED = { CoverProbeFilter.class };
17:
18: /**
19: * No code is covered.
20: */
21: public void testNoFilter() {
22: CoverageDecorator cd = new CoverageDecorator(Coverage.class,
23: COVERED);
24:
25: TestResult result = new TestResult();
26:
27: cd.run(result);
28:
29: // 1 Failure
30: assertEquals(1, result.failureCount());
31:
32: // No errors
33: assertEquals(0, result.errorCount());
34: }
35:
36: /**
37: * Validate that a test covering all of the code, does not cause
38: * any coverage failures or errors.
39: */
40: public void testFilter() {
41: CoverageDecorator cd = new CoverageDecorator(Coverage.class,
42: COVERED, new StringProbeFilter("filterThis()"));
43:
44: TestResult result = new TestResult();
45:
46: cd.run(result);
47:
48: assertEquals(0, result.failureCount());
49:
50: // No errors
51: assertEquals(0, result.errorCount());
52: }
53:
54: /** Does not cover any code. */
55: public static class Coverage extends TestCase {
56: /**
57: * Tests nothing.
58: */
59: public void testClass() {
60: new CoverProbeFilter();
61: }
62: }
63:
64: }
|