01: package org.hanseltest;
02:
03: import java.io.PrintWriter;
04: import java.io.StringWriter;
05:
06: import junit.framework.Test;
07: import junit.framework.TestCase;
08: import junit.framework.TestFailure;
09: import junit.framework.TestResult;
10:
11: import org.hansel.CoverageDecorator;
12:
13: /**
14: * Test for Bug 747017. For inner classes the *.java file is called
15: * MainClass.java not MainClass$InnerClass.java.
16: *
17: * @author Niklas Mehner
18: */
19: public class TestBug747017 extends TestCase {
20: /**
21: * Try to reproduce the bug.
22: */
23: public void testBug() {
24: Test test = BugTest.suite();
25: TestResult result = new TestResult();
26: test.run(result);
27:
28: assertEquals(1, result.failureCount());
29:
30: TestFailure failure = (TestFailure) result.failures()
31: .nextElement();
32:
33: StringWriter sw = new StringWriter();
34: failure.thrownException().printStackTrace(new PrintWriter(sw));
35:
36: assertEquals(sw.toString().indexOf("$BugExample.java"), -1);
37: }
38:
39: public static class BugTest extends TestCase {
40: public static Test suite() {
41: return new CoverageDecorator(BugTest.class,
42: new Class[] { BugExample.class });
43: }
44:
45: /** The test will fail, if no tests are provided. */
46: public void testSomething() {
47: }
48: }
49:
50: /** Example class to be covered. */
51: public static class BugExample {
52: public BugExample(String someString) {
53: }
54: }
55: }
|