Integration testing - mock the DAO

I’m sure others will chime in, but my recommendation is to step back one level and think about using a development database that you can develop and test against. In fact, if you leverage the commandbox-migrations module to “migrate up” and “migrate down” your dev/testing database, you can script in sample data to use for your testing and development purposes. Then you can leverage the cfmigrations module in ColdBox/TestBox to reload the sample data to start each relevant test suite (either unit or integration) and also roll back transactions between each test within the suite. This would eliminate the need to mock the DAO in your integration tests.

3 Likes