JUnit单元测试代码

package com.storage.test;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.storage.dao.UserDAO;

public class TestUser {
    
    ClassPathXmlApplicationContext ctx;
    @Before
    public void init(){
        ctx = new ClassPathXmlApplicationContext("applicationContext.xml","mybatis.xml");
    }
    
    @Test
    public void testAddUser(){
        UserDAO userDAO = ctx.getBean("UserDAO",UserDAO.class);
        userDAO.addUser("admin", "admin");
    }
    
}

 

posted @ 2018-11-27 16:25  admin_jh  阅读(133)  评论(0)    收藏  举报