I have a weird problem. I created a test class by extending StrutsTestCase
.
我有一个奇怪的问题。我通过扩展StrutsTestCase创建了一个测试类。
public class MyActionTest extends StrutsTestCase{
public void helloTest()
{
}
}
The struts documentation says request
of MockHttpServletRequest
will be available by extending StrutsTestCase
. Fair enough, it's a protected variable in StrutsTestCase
so we should have access to it once we extend the class.
struts文档说通过扩展StrutsTestCase可以获得MockHttpServletRequest的请求。很公平,它是StrutsTestCase中的受保护变量,因此我们应该在扩展类后访问它。
But for some reason, NO protected attribute or method of StrutsTestCase
is visible in my MyActionTest
.
但由于某种原因,在我的MyActionTest中可以看到没有受保护的StrutsTestCase属性或方法。
I don't know if I am missing something, but everything seems straight forward, but yet doesn't work.
我不知道我是否遗漏了什么,但一切似乎都很简单,但却行不通。
Any idea as to why the protected methods of super class are not accessible in subclass ? Should I use some specific package or something ?
任何关于为什么超类的受保护方法在子类中不可访问的想法?我应该使用某些特定的包装吗?
List of jars I use for this task :
我用于此任务的罐子列表:
- spring-2.5.3.jar
- spring-mock-1.2.6.jar
- struts2-core-2.0.11.jar
- xwork-core-2.3.1.jar
Am I missing something ?
我错过了什么吗?
2 个解决方案
#1
0
Perhaps struts2-junit-plugin http://struts.apache.org/2.x/docs/junit-plugin.html or struts2-testng-plugin http://struts.apache.org/2.x/docs/testng-plugin.html
也许struts2-junit-plugin http://struts.apache.org/2.x/docs/junit-plugin.html或struts2-testng-plugin http://struts.apache.org/2.x/docs/testng -plugin.html
#2
0
StrutsTestCase is part of the struts2-junit-plugin. See http://struts.apache.org/2.2.3/struts2-plugins/struts2-junit-plugin/apidocs/org/apache/struts2/StrutsTestCase.html - you'll find the protected request variable there.
StrutsTestCase是struts2-junit-plugin的一部分。请参阅http://struts.apache.org/2.2.3/struts2-plugins/struts2-junit-plugin/apidocs/org/apache/struts2/StrutsTestCase.html - 您将在那里找到受保护的请求变量。
Just add that plugin to your classpath and you should be able to use it. Also, don't forget to use the same versions for your struts-core and the plugin.
只需将该插件添加到类路径中,您就可以使用它。另外,不要忘记为struts-core和插件使用相同的版本。
#1
0
Perhaps struts2-junit-plugin http://struts.apache.org/2.x/docs/junit-plugin.html or struts2-testng-plugin http://struts.apache.org/2.x/docs/testng-plugin.html
也许struts2-junit-plugin http://struts.apache.org/2.x/docs/junit-plugin.html或struts2-testng-plugin http://struts.apache.org/2.x/docs/testng -plugin.html
#2
0
StrutsTestCase is part of the struts2-junit-plugin. See http://struts.apache.org/2.2.3/struts2-plugins/struts2-junit-plugin/apidocs/org/apache/struts2/StrutsTestCase.html - you'll find the protected request variable there.
StrutsTestCase是struts2-junit-plugin的一部分。请参阅http://struts.apache.org/2.2.3/struts2-plugins/struts2-junit-plugin/apidocs/org/apache/struts2/StrutsTestCase.html - 您将在那里找到受保护的请求变量。
Just add that plugin to your classpath and you should be able to use it. Also, don't forget to use the same versions for your struts-core and the plugin.
只需将该插件添加到类路径中,您就可以使用它。另外,不要忘记为struts-core和插件使用相同的版本。