package cn.itcast.core.test;
import java.util.Date;
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 cn.itcast.core.dao.TbTestDao;
import cn.itcast.core.pojo.TbTest;
import cn.itcast.core.service.TbTestService;
//spring引入junit4测试环境
@RunWith(value=SpringJUnit4ClassRunner.class)
//加载spring配置文件进而加载spring运行环境
@ContextConfiguration(locations={"application-context.xml"})
public class TestTbTest {
@Autowired
// 注入
private TbTestDao tbDao;
@Autowired
private TbTestService tbService;
@Test
public void testTbTest(){
TbTest tb = new TbTest();
tb.setName("张三");
tb.setBirthday(new Date());
tbDao.insertTest(tb);
}
public void testTbTestService(){
TbTest tb = new TbTest();
tb.setName("李四");
tb.setBirthday(new Date());
tbService.insertTest(tb);
// throw new RuntimeException();
}
}