浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

测试Action - jj - ITeye技术网站

1、添加jar

struts2-junit-plugin-2.1.8.jar             //struts
org.springframework.core-3.0.3.RELEASE.jar //spring
org.springframework.test-3.0.3.RELEASE.jar //spring

 

2、ActionTest extends StrutsTestCase or StrutsSpringTestCase

非ioc action用StrutsTestCase,否则用StrutsSpringTestCase

 

3、编写测试方法

@Test
    
public void testExecute() throws Exception {
        ActionProxy proxy = null;

        request.setParameter("param", "test...");
        proxy = getActionProxy("/test.action");
        String result = proxy.execute();
        assertEquals("success", result);


        TestAction test = null;
        test = (TestAction)proxy.getAction();
        assertEquals("test...", test.getParam());
    }

posted on 2012-03-06 09:29  lexus  阅读(172)  评论(0编辑  收藏  举报