Blog Archives

Testing the DB layer


How to write Junits for DB layer?

One fundamental concept of TDD is that tests should not be interdependent –how do we apply this for DB, A typical step for DB layer test is –emphasizing am talking about the DB testing:

Test that DB server is up
Test that DB exists
Test that Table exists
Add a record

If the first one fails, all other are bound to fail.

For integration tests we can mock these aspects and get going. For now my tests are interdependent and if one fails all fails –indicating that DB layer is not UP. Am continuing till I get a better solution.

Advertisements