[英]Testing DAO file with junit +spring
I'm trying to test a DAO file with junit. 我正在尝试使用junit测试DAO文件。 Is there a way to compare a same query that was performed with 2 different ways?
有没有一种方法可以比较用两种不同方法执行的同一查询?
Does junit supplies a mechanism that uses in two ways to access the DB? junit是否提供一种以两种方式使用来访问数据库的机制?
there are many different was to perform asserts on data using spring and junit . 使用spring和junit对数据执行断言有很多不同。 Here is a starting point :
这是一个起点:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-test.xml"})
@Transactional
public abstract class BaseIntegration {
Then your test classes can extend that and just use the dao as normal, and perform asserts on any data. 然后,您的测试类可以对其进行扩展,并像往常一样使用dao,并对任何数据执行断言。
您可以使用Assert类中的方法比较查询结果
要测试DAO,可以使用DBUnit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.