KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hanseltest > TestBug582985


1 package org.hanseltest;
2
3 import junit.framework.TestCase;
4 import junit.framework.TestResult;
5
6 import org.hansel.CoverageDecorator;
7 import org.hansel.Util;
8
9 /**
10  * Test for bug 582985. This bug occured, because
11  * classes were instrumented two times.
12  *
13  * @author Niklas Mehner
14  */

15 public class TestBug582985 extends TestCase {
16
17     /**
18      * Test for bug 582985.
19      */

20     public void testBug582985() {
21         CoverageDecorator cover =
22                 new CoverageDecorator(new Class JavaDoc[] { CoverMe.class,
23                                                     CoverMe2.class });
24
25         cover.addTestSuite(CoverMeTest.class);
26         cover.addTestSuite(CoverMeTest2.class);
27         
28         TestResult result = new TestResult();
29
30         cover.run(result);
31
32         Util.dumpResult(result);
33         assertEquals(0, result.failureCount());
34     }
35
36     /**
37      * CoverMe is a simple class that is to be covered
38      * by the CoverMeTest.
39      */

40     public static class CoverMe {
41         /** Test variable. */
42         private String JavaDoc name = null;
43   
44         /**
45          * Simple constrcutor.
46          * @param aName initial value of name.
47          */

48         public CoverMe(String JavaDoc aName) {
49             name = aName;
50         }
51     }
52     
53     /**
54      * Very simple testcase. The contents is not really
55      * important, but should totally cover the CoverMe
56      * class.
57      */

58     public static class CoverMeTest extends TestCase {
59         /**
60          * Constructor for the TestCase.
61          * @param name Name of the test.
62          */

63         public CoverMeTest(String JavaDoc name) {
64             super(name);
65         }
66
67         /** Test the constructor. */
68         public void testConstructor() {
69             CoverMe covered = new CoverMe("please");
70         }
71     }
72
73     /**
74      * Same as CoverMe.
75      */

76     public static class CoverMe2 {
77         /** Test variable. */
78         private String JavaDoc name = null;
79
80         /**
81          * Simple constrcutor.
82          * @param aName initial value of name.
83          */

84         public CoverMe2(String JavaDoc aName) {
85             name = aName;
86         }
87     }
88     
89     /**
90      * Second testcase. This is the same as CoverMeTest.
91      */

92     public static class CoverMeTest2 extends TestCase {
93
94         /**
95          * Constructor for the TestCase.
96          * @param name Name of the test.
97          */

98         public CoverMeTest2(String JavaDoc name) {
99             super(name);
100         }
101
102         /** Test the constructor. */
103         public void testConstructor() {
104             CoverMe2 covered = new CoverMe2("please");
105         }
106     }
107 }
108
Popular Tags