users
[Top] [All Lists]

Re: [cinjug-users] Eclipse - Create an abstract subclass of a class w/o

To: Scott T Weaver <sweaver@xxxxxxxxxxxxxxx>
Subject: Re: [cinjug-users] 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 15:14:08 -0400
Cc: users@xxxxxxxxxx
Delivered-to: mailing list users@cinjug.org
In-reply-to: <200505171908.j4HJ8JZ08117@sunlist.sdrc.com>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
References: <200505171908.j4HJ8JZ08117@sunlist.sdrc.com>
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)
Amol/Scott,

As far as I can tell, Eclipse is using 3.8.1. It's the same version that I have in the class path. Amol, The default constructor is not public in 3.8.1.

Can you try this in your eclipse:

Try to create:

import junit.framework.TestCase;

public abstract class AbstractTestCase extends TestCase {

}

Brian



Scott T Weaver wrote:

Brian,

I think I have seen this before.  Eclipse might be using an older version of
JUnit when a constructor was required.  Try changing the version Eclipse
uses to the one you are using on the command line.

-Scott



-----Original Message-----
From: Brian Bonner [mailto:brian.bonner@xxxxxxxxxxxx]
Sent: Tuesday, May 17, 2005 2:46 PM
To: users@xxxxxxxxxx
Subject: [cinjug-users] Eclipse - Create an abstract subclass of a class
w/o a default constructor. / running TestCase w/o constructor in Eclipse

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(RemoteTest
Runner.java:436)
   at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunne
r.java:311)
   at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunn
er.java:192)


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

Any thoughts?

--

Brian


--------- You may unsubscribe from this mailing list by sending a blank email addressed to: users-unsubscribe@xxxxxxxxxx

--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx





--------- You may unsubscribe from this mailing list by sending a blank email addressed to: users-unsubscribe@xxxxxxxxxx

--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx




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