Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

A regression of the art of database development

By Phil Factor,

Today we have a guest editorial from Phil Factor.

There has been much excitement recently about Database Unit Testing. Much in the same way as the sixties hippies felt they’d invented sex, a few writers have implied that database developers were completely innocent of any unit testing or regression testing methodologies before they came upon the scene with their splendid ideas, products, and insights.

Those of us who’ve worked in the industry a long time were trained in the arts of using structured and automated test harnesses for our code, even before it was delivered to the test teams. This practice was carried over to relational databases, when they appeared, just as it been intrinsic in mainframe practice, particularly in financial and trading systems.

Even automation, by itself, is hardly new: To develop and maintain database code and schemas at any speed or reliability, your regression testing has always had to be pretty seriously automated. Edge cases, soak tests and limit tests are best left to professional testers, but nothing else. I still wince at the reproach I used to get, as a cub programmer, if a simple error slipped through to them. I can also remember, thirty years ago, being instructed to build the test harness before writing the code. It concentrates the mind on what you’re designing. In developing serious financial systems, unit testing was always done before the code was delivered, as the code was built.

There is no mystery to how to test a deterministic routine. You feed it a variety of inputs and check that the output is exactly what you expect. If possible, you also run tests with randomly generated input, and verify the results by hand. You run the batches automatically every time you make a change or make a build. With a database, you need a range of test data, and to run a session with a typical query workload on it. It is a constant surprise to some developers to find out just how many bugs get flushed out by such a simple ritual, ‘How could such a simple change have had that effect?’

Although Database Unit Testing has a long and honorable history, there have been recent, significant developments. Recent work, by Alex Kuznetsov, on replicating deadlocks comes to mind. There is much to gain, for example, from developing more sophisticated client-based test harnesses that can simulate real usage. I share with the proponents of test-driven development a fascination for the whole subject of database test harnesses and test data, and their automatic generation: but to claim that any of this is new is all phooey.

Total article views: 346 | Views in the last 30 days: 2
 
Related Articles
ARTICLE

Database Restore Automation

Read about Paul Brewer's Framework (Version 2) for Database Restore Automation.

SCRIPT

Automate Test Database Restoration

Automate test database restorations from your production system.

BLOG

Azure Automation

I introduced Azure Automation in a previous post. I’ve spent some more time exploring it. There’s a...

ARTICLE

Automate Your Backup and Restore Tasks

A new article that shows how you can automate a basic function that many environments need: the back...

FORUM

Is it Ok.doing Database Restoration as a Automated Proccess.

Is it Ok.doing Database Restoration as a Automated Proccess.

Tags
editorial    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones