欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Junit4在Spring4+SpringMVC+MyBatis下的使(Eclipse版)

程序员文章站 2022-07-12 14:01:47
...

一、创建测试类,比如对dao方法测试。

Junit4在Spring4+SpringMVC+MyBatis下的使(Eclipse版)

Junit4在Spring4+SpringMVC+MyBatis下的使(Eclipse版)

二、创建BaseTest类

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/applicationContext-base.xml")
public class BaseTest extends AbstractTransactionalJUnit4SpringContextTests{
//AbstractTransactionalJUnit4SpringContextTests 解决测试时事务问题
}

三、继承BaseTest类,编写测试内容

public class PropertyPOMapperTest extends BaseTest{
	
	@Autowired
	private PropertyPOMapper mapper;

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testSelectByPrimaryKey() {
		PropertyPO po = mapper.selectByPrimaryKey(964);
//		List<PropertyPO> list = mapper.selectAllPropertys();
		String ii = po.getPropertyName();
		System.out.println("=======**********=========");
		System.out.println(ii);
		fail("Not yet implemented");
	}
	
	
}


相关标签: Junit4