users
[Top] [All Lists]

Eclipse - Create an abstract subclass of a class w/o a default construct

To: users@xxxxxxxxxx
Subject: Eclipse - Create an abstract subclass of a class w/o a default constructor. / running TestCase w/o constructor in Eclipse
From: Brian Bonner <brian.bonner@xxxxxxxxxxxx>
Date: Tue, 17 May 2005 14:46:12 -0400
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)
Has anyone run into this problem?

I'm trying to use an abstract subclass of a class that doesn't have a default constructor (TestCase). For some reason, Eclipse complains that the default constructor with a name is needed to run it in Junit, however, I can compile the same code at a command line and it works in JUnit w/o problem.

Here's my code to reproduce the problem: The AbstractTestCase compiles outside of eclipse and runs in JUnit fine.

/** Abstract Test Case w/ no constructors */
import junit.framework.TestCase;
public abstract class AbstractTestCase extends TestCase {
// Eclipse complains that the Implicit Super Constructor TestCase()
// is not visible for default constructor. Must define an explicit constructor.
}


Likewise, if I try to use the AbstractTestCase in another TestCase as shown below, Eclipse complains that there is no default constructor when I try to run it in JUnit.

/** another test case  which uses the abstract Test Case */
public class AnotherTest extends AbstractTestCase {
public AnotherTest(String name){
}

junit.framework.AssertionFailedError: Class AnotherTest has no public constructor TestCase(String name)
at junit.framework.Assert.fail(Assert.java:51)
at junit.framework.TestSuite$1.runTest(TestSuite.java:225)
at junit.framework.TestCase.runBare(TestCase.java:140)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)



AnotherTest *can't* have a constructor of TestCase(String name), because AbstractTestCase suppressed it.


Any thoughts?

--

Brian


<Prev in Thread] Current Thread [Next in Thread>