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");
    }
    
}

猜你喜欢

转载自www.cnblogs.com/suhfj-825/p/10027115.html