Question

The software development team at my company develops using TDD and BDD practices. Consequently we have lots of unit, integration and acceptance tests to let us know whether our code base is working as expected. Needless to say, we now could not live without these tests giving us constant feedback.

The development DBA on our team writes table views with complex logic. He develops these without unit tests, and they invariably break when he does subsequent development, causing frustration in the software development team.

My question is, are DBAs encouraged to use TDD practices when working in an agile environment? Do DBA's have test frameworks to allow them to work in this way? We use IBM's DB2 database; are there any test frameworks for this database to allow database views to be developed in a TDD manner?

Was it helpful?

Solution

In the past I've used two approaches:

  1. Having a very thin Data Access layer in the application and writing tests around that. In other words (assuming your dba uses sprocs), for each new sproc a method to access it is written and a test is created which exercises it appropriately (or better, tests first). This is nice because it integrates easily with test runners. You can use transactions to rollback tests without side effects.

  2. Another option is to use native SQL testing frameworks. I've evaluated tsqlt which is a SQL Server framework, so not appropriate in your case, but the approach is solid and there could be appropriate frameworks for DB2.

OTHER TIPS

There are several framework to test routines in the different kind of databases. Some of them follow the xUnit specification, and this allows to have jUnit-like tests at database level.

For DB2, there is a framework called db2unit: https://github.com/angoca/db2unit

With this framework you can compare objects (numbers, dates, boolean, strings, etc.) like you do in jUnit.

You can include the result of your database level tests into the global tests by capturing the error code, and this can be included in a Continuous Integration system. db2unit uses Travis-CI to test itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top