如何以Junit 4方式测试Struts2动作? [英] How to test Struts2 action in Junit 4 way?

查看:96
本文介绍了如何以Junit 4方式测试Struts2动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个struts2-junit-plugin用于测试Struts2动作,但是它似乎要求测试以JUnit 3样式编写,也就是说,我不能使用@ BeforeClass,@ Test等注释,也不能使用BDD样式的测试名称,例如"shouldDoThisAndThat()".有没有办法将struts2-junit-plugin和JUnit 4风格的测试结合起来?

There's a struts2-junit-plugin for testing Struts2 actions, but it seems to require the tests to be written in JUnit 3 style, that is I can't use @BeforeClass, @Test etc annotations and can't use BDD-style test names like "shouldDoThisAndThat()". Is there a way to combine struts2-junit-plugin and JUnit 4-style tests?

推荐答案

您可能想尝试一下:

http://glindholm.wordpress.com /2008/06/30/unit-testing-struts-2-actions/

我发现它在测试Struts2动作中非常有用.它使用Mockrunner来模拟在servlet容器中的运行,因此您可以使用任意方式开发测试,包括使用JUnit 4.

I have found it to be very useful in testing Struts2 actions. It uses Mockrunner to simulate running in a servlet container, so you can develop your tests in any way you like, including using JUnit 4.

这篇关于如何以Junit 4方式测试Struts2动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆