zoukankan      html  css  js  c++  java
  • Junit单元测试类

    /*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);
        }
    }
    */
  • 相关阅读:
    2017福建夏令营Day7(数论)
    2017福建夏令营Day3(搜索)
    【FZSZ2017暑假提高组Day9】猜数游戏(number)
    【FZSZ2017暑假提高组Day6】bd
    POJ 3660 传递闭包问题
    NOIP 提高组 2002 均分纸牌
    POJ 2387 Til the Cows Come Home
    NOIP 2016 Day2 T1 组合数问题
    06--ubuntu的sqlite安装
    ARM架构与体系学习(二)——3级流水线
  • 原文地址:https://www.cnblogs.com/colmeluna/p/3739388.html
Copyright © 2011-2022 走看看