001: package org.hanseltest;
002:
003: import junit.framework.TestCase;
004: import junit.framework.TestResult;
005:
006: import org.hansel.CoverageDecorator;
007: import org.hansel.Util;
008:
009: /**
010: * Test for bug 582985. This bug occured, because
011: * classes were instrumented two times.
012: *
013: * @author Niklas Mehner
014: */
015: public class TestBug582985 extends TestCase {
016:
017: /**
018: * Test for bug 582985.
019: */
020: public void testBug582985() {
021: CoverageDecorator cover = new CoverageDecorator(new Class[] {
022: CoverMe.class, CoverMe2.class });
023:
024: cover.addTestSuite(CoverMeTest.class);
025: cover.addTestSuite(CoverMeTest2.class);
026:
027: TestResult result = new TestResult();
028:
029: cover.run(result);
030:
031: Util.dumpResult(result);
032: assertEquals(0, result.failureCount());
033: }
034:
035: /**
036: * CoverMe is a simple class that is to be covered
037: * by the CoverMeTest.
038: */
039: public static class CoverMe {
040: /** Test variable. */
041: private String name = null;
042:
043: /**
044: * Simple constrcutor.
045: * @param aName initial value of name.
046: */
047: public CoverMe(String aName) {
048: name = aName;
049: }
050: }
051:
052: /**
053: * Very simple testcase. The contents is not really
054: * important, but should totally cover the CoverMe
055: * class.
056: */
057: public static class CoverMeTest extends TestCase {
058: /**
059: * Constructor for the TestCase.
060: * @param name Name of the test.
061: */
062: public CoverMeTest(String name) {
063: super (name);
064: }
065:
066: /** Test the constructor. */
067: public void testConstructor() {
068: CoverMe covered = new CoverMe("please");
069: }
070: }
071:
072: /**
073: * Same as CoverMe.
074: */
075: public static class CoverMe2 {
076: /** Test variable. */
077: private String name = null;
078:
079: /**
080: * Simple constrcutor.
081: * @param aName initial value of name.
082: */
083: public CoverMe2(String aName) {
084: name = aName;
085: }
086: }
087:
088: /**
089: * Second testcase. This is the same as CoverMeTest.
090: */
091: public static class CoverMeTest2 extends TestCase {
092:
093: /**
094: * Constructor for the TestCase.
095: * @param name Name of the test.
096: */
097: public CoverMeTest2(String name) {
098: super (name);
099: }
100:
101: /** Test the constructor. */
102: public void testConstructor() {
103: CoverMe2 covered = new CoverMe2("please");
104: }
105: }
106: }
|