You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Maarten Volders <Ma...@cronos.be> on 2002/11/14 16:38:53 UTC

RE still a problem: RE: StrutsTestCase + overriding setUp without calling super.setUp() ERROR

Still the same problem here, he's still complaining that i'm overriding
setUp() but that I have to implement super.setUp(), but you can see
clearly in my code that I implement that method.

Anyone with other suggestions??? I'm using Intellij 3.0 to run my unit
test, but al my other unit tests run fine with it so I don't see the
problem here.

Thx

--- code ---
package be.milieuinfo.cbb.ui;

import servletunit.struts.MockStrutsTestCase;

public class SearchXtantActionTest extends MockStrutsTestCase {

    public void setUp() {
        try {
            super.setUp(); // !!!!!!!!!!!
        } catch(Exception e) {}
    }

    public SearchXtantActionTest(String testName) {
        super(testName);
        setConfigFile("E:/CBB/xml/web/UI");
    }

    public void testLogonSuccess() {
        System.out.println("test");
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(SearchXtantActionTest.class);
    }
}
------------------


You need to call super.setUp() before super(testname) . 
I found that adding the following code: 
public void setUp() { 
try{ super.setUp(); } catch(Exception e){ } }
 made it work correctly. 
---------------------------



Hi, i'm just starting to use the wonderfull world of extra work :) using
the StrutsTestCase. But when I try the test a rather basic program then
I get the error (see at the end of the page) that I'm overriding the
setUp methode and, but I'm NOT overriding it??? I have tried to override
the setUp methode, including the super.setUp() method, but he still
gives the same error??? 

Has anyone had this problem before?

Thx

using JUnit 3.7 and Tested it on StrutsTestCase v1.8 and 1.9, but the
same problem on each of the versions.

--------- Begin code ---------
import servletunit.struts.MockStrutsTestCase;

public class SearchXtantActionTest extends MockStrutsTestCase {

    public SearchXtantActionTest(String testName) {
        super(testName);
    }

    public void testLogonSuccess() {
        System.out.println("test 123");
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(SearchXtantActionTest.class);
    }
}
--------- end code ---------


--------- Begin error ---------
warning(junit.framework.TestSuite$1)junit.framework.AssertionFailedError
: Exception in constructor: testLogonSuccess
(junit.framework.AssertionFailedError: You are overriding the setUp()
method without calling super.setUp().  You must call the superclass
setUp() method in your TestCase subclass to ensure proper
initialization.
	at
servletunit.struts.MockStrutsTestCase.init(MockStrutsTestCase.java:91)
	at
servletunit.struts.MockStrutsTestCase.setConfigFile(MockStrutsTestCase.j
ava:337)
	at
be.milieuinfo.cbb.ui.SearchXtantActionTest.<init>(SearchXtantActionTest.
java:9)
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at
be.milieuinfo.cbb.ui.SearchXtantActionTest.main(SearchXtantActionTest.ja
va:18)
)
	at
be.milieuinfo.cbb.ui.SearchXtantActionTest.main(SearchXtantActionTest.ja
va:18)
--------- End error ---------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: RE still a problem: RE: StrutsTestCase + overriding setUp without calling super.setUp() ERROR

Posted by Chris Winters <cw...@optiron.com>.
On Thu, 2002-11-14 at 10:38, Maarten Volders wrote:
> Still the same problem here, he's still complaining that i'm overriding
> setUp() but that I have to implement super.setUp(), but you can see
> clearly in my code that I implement that method.
> 
> Anyone with other suggestions??? I'm using Intellij 3.0 to run my unit
> test, but al my other unit tests run fine with it so I don't see the
> problem here.
>
>     public void setUp() {
>         try {
>             super.setUp(); // !!!!!!!!!!!
>         } catch(Exception e) {}
>     }
> 
>     public SearchXtantActionTest(String testName) {
>         super(testName);
>         setConfigFile("E:/CBB/xml/web/UI");
>     }

I'm pretty sure you need to move setConfigFile() to setUp() (after
super.setUp()) rather than putting it in the constructor.

Chris

-- 
Chris Winters (cwinters@optiron.com)
Java Developer


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>