Dharun
Dharun

Reputation: 21

How to write Junit test for to check data that I selected from DB and the Data that I have inserted in DB

I have Business component, Controller,Service,ServiceImpl. I have selected data from DB using stringBuilder and performed some calculations and inserted data from the variables that I took from DB. How to write Junit test for to check data that I selected from DB and the Data that I have inserted in DB?

Upvotes: 2

Views: 577

Answers (1)

Vladimir.V.Bvn
Vladimir.V.Bvn

Reputation: 1118

You can use DBUnit tool. Generally the tool is able to generate "expected" dataset from xml files, connect to database and retrieve "actual" dataset and check assertions. Examples are here: https://www.baeldung.com/java-dbunit

Upvotes: 1

Related Questions