JUnit4单元测试dao、service、controller

package org.tonny.test;

 

import java.util.List;

 

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.test.context.ContextConfiguration;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.transaction.annotation.Transactional;

import org.tonny.map.IUserMapper;

import org.tonny.model.UserInfo;

 

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(locations = {"classpath:spring.xml"})

@Transactional

public class MyUnitTest {

@Autowired

    private IUserMapper userMapper;

@Test

public void testSelect() {

List all = userMapper.getAll();

    System.out.println(all);

}

}

你可能感兴趣的:(java基础部分)