Database and SQL testing

In many of the examples a Data Access Object (DAO) class is responsible for retrieving or persisting information in the database. Whenever these classes appear, we quickly stub or mock them out of our way. However, at some point, you need to test these classes. These DAOs often perform complex SQL queries, and they encapsulate a lot of business knowledge, requiring testers to spend some energy making sure they produce the expected outcomes. The following sections examine what to test in a SQL query, how to write automated test cases for such queries, and the challenges and best practices involved.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *