zoukankan      html  css  js  c++  java
  • UnitilsJUnit4Test功能介绍

    UnitilsJUnit4BaseTest.java文件:

    /**
     * 
     */
    package unitilsjunit4test;
    
    import org.junit.runner.RunWith;
    import org.unitils.UnitilsJUnit4TestClassRunner;
    import org.unitils.spring.annotation.SpringApplicationContext;
    
    /**
     * @author Administrator
     *
     */
    @SpringApplicationContext({ "classpath*:core/persistence/beans.xml" })
    @RunWith(UnitilsJUnit4TestClassRunner.class)//或者BaseTest继承extends UnitilsJUnit4
    public class UnitilsJUnit4BaseTest {
    
    }

    UnitilsJUnit4Test.java文件:

    /**
     * Copyright (C) 2006-2012 Tuniu All rights reserved
     * Author:tianzhipeng
     * Date:2012-7-9
     * Description: 
     */
    
    package unitilsjunit4test;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import javax.servlet.http.HttpServletRequest;
    
    import junit.framework.Assert;
    
    import org.junit.Test;
    import org.unitils.spring.annotation.SpringBeanByType;
    
    import core.domain.User;
    import core.service.IUserService;
    
    /**
     * Description : Menpiao unit test
     */
    
    //@SpringApplicationContext({ "classpath*:core/persistence/beans.xml" })
    //@RunWith(UnitilsJUnit4TestClassRunner.class)
    public class UnitilsJUnit4Test extends UnitilsJUnit4BaseTest{
        @SpringBeanByType
        private IUserService userService;
    
        @Test
        public void testSaveMenpiao() {
            Map<String, Object> data = new HashMap<String, Object>();
            User user = userService.getUserByName("tom");
            System.out.println(user.getName());
            Assert.assertEquals(user.getName(), "tom");
        }
    
        @Test
        public void testGetRequest() {
            HttpServletRequest request = null;
        }
    }

    需要jar包:junit-4.10.jar,unitils-2.4.jar

  • 相关阅读:
    Pro*C,oci,occi的作用以及区别联系?
    图片缩放 剪切
    去除DataGridView选中行背景色的方法
    重写DataGridView的sort方法 自定义排序
    很好用的js日历 kimsoftjscalendar 感谢KimSoft
    计时器例子
    gcc与g++有什么区别?
    VB.NET全角半角check
    Java 集合框架(Collection)和数组的排序
    Click Models for Web Search(1) Basic Click Models
  • 原文地址:https://www.cnblogs.com/usual2013blog/p/2667309.html
Copyright © 2011-2022 走看看