码迷,mamicode.com
首页 > 其他好文 > 详细

Junit单元测试类

时间:2014-05-21 05:20:31      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   c   code   java   

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单元测试类

标签:style   blog   class   c   code   java   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!