package test;
import entity.Product;
import mapper.ProductMapper;
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;
//@RunWith(SpringJUnit4ClassRunner.class),让测试运行于Spring测试环境
@RunWith(SpringJUnit4ClassRunner.class)
//用于测试加载spring环境常与@RunWith联用
@ContextConfiguration(locations = "classpath:application.xml")
public class TestMapper {
@Autowired
private ProductMapper mapper;
@Test
public void test1(){
Product p = new Product();
p.setTid(1);
p.setPname("aaa");
mapper.add(p);
}
@Test
public void test2(){
mapper.delete(2);
}
}