开发者

StrutsTestCase test and "error" returned from Struts2 action class

开发者 https://www.devze.com 2023-01-04 17:23 出处:网络
I\'m trying to use StrutsTestCase for testing my Struts2 actions, but I\'m getting always the "error" value back while executing the &quo开发者_StackOverflow社区t;execute()" method from

I'm trying to use StrutsTestCase for testing my Struts2 actions, but I'm getting always the "error" value back while executing the &quo开发者_StackOverflow社区t;execute()" method from the proxy. Here's the example:

public void testSpike() throws Exception{

    request.addHeader("param1", "param");
    
    ActionProxy proxy = getActionProxy("/action/to/test.action");
    assertNotNull(proxy);

    TestAction action = (TestAction) proxy.getAction();
    assertNotNull(action);

    String output = proxy.execute();

}

the output string is always "error". Is there a way to understand what happened there? The logs are not saying anything, and even trying to debug placing a breakpoint on the Action class doesn't help (the code never stops there).

Any suggestions?

Thanks Roberto


Add a breakpoint at the line 'String output = proxy.execute();'. Execute your test in debug mode in your favorite IDE and step through the code to realize why execute() method returns always 'error'.

0

精彩评论

暂无评论...
验证码 换一张
取 消