Database Automated Testing

Unit tests generally includes 3 parts: ARRANGE, ACT, ASSERT. there is little difference over ARRANGE/ACT between database unit testing and typical Java unit testing, however, ASSERT when testing database stored procedure might be very special.

1. Concerns

(1) Expected result may be a table, rather than a scalar value, how to compare expected result and actual result?


2. Visual Studio Database Unit Tests

Unfortunately, only Visual Studio Ultimate/Premium supports database unit tests, no Professional edition support. Anyway, we may learn something from its official documentation.


3. DbFit


4. Invent Your Proprietary Testing Tool

A couple of years ago, I wrote some Nunit tests for optimizing stored procedures, it works well but really trivial and time-consuming to code results comparing. 

By the way, Reference 1 also works in this way.


References:
1. https://www.simple-talk.com/sql/database-administration/close-those-loopholes-lessons-learned-from-unit-testing-t-sql/
2. http://dbfit.github.io/dbfit/docs/whats-wrong-with-xunit.html

你可能感兴趣的:(Database Automated Testing)