您的位置:首页 > 编程语言 > Java开发

单元测试与Spring整合的struts2中的action

2014-11-21 15:09 465 查看
环境描述:Struts2  + Spring2.5   +  hibernate3 +  junit4

目的:对后台Action层的函数进行单元测试

需要的Jar包:junit4.jar(eclipse自带的,在项目路径中导入即可。“properties->Add Library->JUnit->JUnit4”) struts2-junit-plugin-2.1.8.jar spring-test.jar

public class UserAction_Junit extends StrutsSpringTestCase {

    

    protected String getContextLocations() {  

        return "classpath*:beans*.xml";  

    }  

    

    @Test

    public void testGetUsers() throws Exception {

        String result = executeAction("/user!getUsers.action");

        System.out.println(result);

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: