KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hansel > AssertionCoverageDecorator


1 package org.hansel;
2
3 import org.hansel.probes.ProbeFilter;
4
5 public class AssertionCoverageDecorator extends CoverageDecorator {
6
7     public AssertionCoverageDecorator(Class JavaDoc[] classesCovered) {
8         super(classesCovered, new AssertionProbeFilter());
9     }
10
11     public AssertionCoverageDecorator(Class JavaDoc testClass,
12                                       Class JavaDoc[] classesCovered) {
13         super(testClass, classesCovered, new AssertionProbeFilter());
14     }
15
16     private static class AssertionProbeFilter implements ProbeFilter {
17         public boolean filter(ProbeData probeData) {
18             if (probeData.getStackSize() == 0) {
19                 return false;
20             }
21             
22             String JavaDoc stackString = probeData.getStackEntry(0).toString();
23             
24             return stackString.equals("$assertionsDisabled") ||
25             stackString.endsWith(".desiredAssertionStatus()");
26         }
27     }
28 }
29
Popular Tags