简体   繁体   English

StrutsTestCase测试和Struts2操作类返回的“错误”

[英]StrutsTestCase test and “error” returned from Struts2 action class

I'm trying to use StrutsTestCase for testing my Struts2 actions, but I'm getting always the "error" value back while executing the "execute()" method from the proxy. 我正在尝试使用StrutsTestCase测试我的Struts2操作,但是在从代理执行“ execute()”方法时,我总是会得到“错误”值。 Here's the example: 这是示例:

public void testSpike() throws Exception{ 公共无效testSpike()引发异常{

  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). 日志没有说什么,甚至尝试调试在Action类上放置断点也无济于事(代码永不止步于此)。

Any suggestions? 有什么建议么?

Thanks Roberto 谢谢罗伯托

Add a breakpoint at the line 'String output = proxy.execute();'. 在“字符串输出= 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'. 在您喜欢的IDE中以调试模式执行测试,并逐步执行代码以了解为什么execute()方法始终返回“错误”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM