Amol,
You are getting a runtime error,
When you use the empty constructor for TestCase, fName is set to null,
by the empy constructor.
It looks like you have at least 2 opt6ions:
1) Give the test case a name by using the non-empty constructor for
TestCase (this is what I do)
2) override runTest
Hope this is helpful,
Mike
----------------- runTest -----------------
/**
* Override to run the test and assert its state.
* @exception Throwable if any exception is thrown
*/
protected void runTest() throws Throwable {
assertNotNull(fName);
Method runMethod= null;
try {
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
|
|