users
[Top] [All Lists]

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

To: Amol Deshmukh <adeshmukh@xxxxxxxxxxxxxx>
Subject: Re: [cinjug-users] Eclipse - Create an abstract subclass of a cla ss w/o a default constructor. / running TestCase w/o constructor in Eclip se
From: Brian Bonner <brian.bonner@xxxxxxxxxxxx>
Date: Tue, 17 May 2005 15:49:48 -0400
Cc: Scott T Weaver <sweaver@xxxxxxxxxxxxxxx>, users@xxxxxxxxxx
Delivered-to: mailing list users@cinjug.org
In-reply-to: <E58DC1ED41D5D411AAEE00B0D078F16208EF7935@arnie.collegeview.com>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
References: <E58DC1ED41D5D411AAEE00B0D078F16208EF7935@arnie.collegeview.com>
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)
Amol, thanks for the comment about the default constructor showing as public. Apparently someone labeled the junit version as 3.8.1. The version included with eclipse has it as public and it works fine. Thanks.

Brian



Amol Deshmukh wrote:

Brian,

I tried the code for your AbstractTestCase and it
shows no compile issues.


Incidentally, my version of Junit shows the default constructor as public.



The best way to find which version of JUnit is being used
is to Ctrl+click on the TestCase class and click on "Link with editor" in the package explorer to see which jar containing the the TestCase class is being linked.
The referenced jar should show an empty package: "junit3.8.1"
if you intend to use 3.8.1



~ amol







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


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.runTe


sts(RemoteTest


Runner.java:436)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R


emoteTestRunne


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





---------
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>