简体   繁体   中英

Testing DAO file with junit +spring

I'm trying to test a DAO file with junit. 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?

there are many different was to perform asserts on data using spring and 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.

您可以使用Assert类中的方法比较查询结果

要测试DAO,可以使用DBUnit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM