首页 > 其他 > 详细

Junit单元测试类

时间:2014-05-21 05:21:14      阅读:386      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
/*package zxdc.web;

import static org.junit.Assert.*;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import static org.easymock.EasyMock.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import zyzy.common.util.Common;

public class JunitEx {
        private Common servlet;  
        private HttpServletRequest mockRequest;  
        private HttpServletResponse mockResponse;  

    public JunitEx(){
        
    }
    @Before
    public void setUp()throws Exception{
        servlet = new Common();  
        
        mockRequest = createMock(HttpServletRequest.class);          
        mockResponse = createMock(HttpServletResponse.class);  
    }
    @After
    public void tearDown()throws Exception{
        verify(mockRequest);         
        verify(mockResponse);  
    }
    
    
     @Test  
        public void testDoPostHttpServletRequestHttpServletResponse() throws ServletException, IOException {  
              
            mockRequest.getParameter("id");          
            expectLastCall().andReturn("1");  
              
           
            replay(mockRequest);                     
            replay(mockResponse);  
              
            servlet.doPost(mockRequest, mockResponse);   
                      
        }  
      
    @Test
    public void xmlsql(){
        String provinceid="12";
        Common xmlCommon=new Common();
        String resultString=xmlCommon.provinceIdEXprovinceCodeFromXml(provinceid);
        System.out.println(resultString);
        String expResult="0";
        assertEquals(expResult,resultString);
    }
    @Test
    public void getHalfYearId(){
        Common xmlCommon=new Common();
        String resultString=xmlCommon.getHalfYearId();
        String expResult="0";
        System.out.println(resultString);
        //assertEquals(expResult,resultString);
    }
}
*/
bubuko.com,布布扣

 

Junit单元测试类,布布扣,bubuko.com

Junit单元测试类

原文:http://www.cnblogs.com/colmeluna/p/3739388.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!