How can I write JUnit tests for CRUD operations of an application(Java application). I use MyBatis as data mapper over database.
For example I have a query as this:
SELECT * FROM sm.PERSON WHERE name='something'
And I call this query from MyBatis:
java.util.List<Person> persons = SqlMapClient.openSession().queryForList(queryName)
Now how can I test this operation to get that the result is right?
(Another thing please tell me title of books for learning Testing in java. I know the basics and I want to get deeper.)
I think your Junit test should run standalone without depending on database results.
In your case you need to test using the database, you can use DbUnit, an junit extension targeted for database-driven projects.
For the ebook :