InfoQ

News

Cory Foy on Database Unit Testing

Posted by James Vastbinder on Oct 21, 2007 01:33 PM

Community
.NET,
Agile
Topics
Unit Testing ,
Artifacts & Tools
Tags
Database ,
SQL Server 2008

Unit testing at the database level has always been tough.  Until recently most developers working at the database level simply avoided unit testing their logic and stored procedures.  In this InfoQ article, Cory Foy demonstrates how to implement Test Driven Development within the database for SQL Server.

With the techniques outlined in his article and Visual Studio for Database Professionals, developers:

  • know where the true representation of the database is stored
  • are enabled to modify the schema and forward changes to be modified to a DBA for approval
  • are able to make changes to the schema while understanding the impact of their changes
  • provided the ability to unit test stored procedures including how to generate test data

There is one caveat, currently this process only works with SQL Server databases.  

Related Sponsor

VersionOne is recognized by Agile practitioners as the leader in Agile project management tools. Companies such as Adobe, BBC, CNN, Dow, HP, IBM, Sony and 3M have turned to VersionOne to help deliver greater value to their customers.
Excellent article - too bad abot MS pricing by Steve Macdonald Posted Oct 18, 2007 5:45 PM
Support for Oracle and Multiple vers of SQLServer Using one set of Scripts? by Sean Creedon Posted Oct 19, 2007 4:00 AM
Re: Support for Oracle by Cory Foy Posted Oct 19, 2007 9:15 AM
Intro another DB unit testing tool by harry har Posted Apr 21, 2009 3:57 AM
  1. Back to top

    Excellent article - too bad abot MS pricing

    Oct 18, 2007 5:45 PM by Steve Macdonald

    This article shows that MS has come a long way with their tools. The problem is that unless you work for a well-heeled organization MS has priced the Team stuff out of reach for most people.

  2. If it supported Oracle and you could share the unit tests, then this would be a real plus for people that write products that need to run on multiple databases. If not Oracle is it easy to test across multiple versions of SQL Server?

  3. Back to top

    Re: Support for Oracle

    Oct 19, 2007 9:15 AM by Cory Foy

    Hi Sean, From what I understand the team is working to create a version which will use a provider model so that other DBMS can be used. Out of the box DBPro works on both 2000 and 2005. The scripts should be able to run against any datasource - the offline schema and tests are in separate projects. Cory

  4. Back to top

    Intro another DB unit testing tool

    Apr 21, 2009 3:57 AM by harry har

    Good article! Now I am glad to share one database unit testing tool. It is named as AnyDbTest (www.anydbtest.com). AnyDbTest Express edition is free of charge. I know some guys are using DbUnit or other xUnit test framework to perform DB unit testing. I also tried to use them in my projects, but at last I had to give up these tools because I must keep focus on the database rather than switch to be as application developer. AnyDbTest is declarative style testing tool. We will not need to program at all. What we do is to express what we want to test, rather than how to test. We only need to configure an Xml test file to tell AnyDbTest what we want to test. Rather than painstakingly writing test code for xUnit test framework. So AnyDbTest is the right choice for DBA or DB developers. Features specific to AnyDbTest: *Writing test case with Xml, rather than Java/C++/C#/VB test case code. *Many kinds of assertion supported, such as StrictEqual, SetEqual, IsSupersetOf, Overlaps, and RecordCountEqual etc. *Allows using Excel spreadsheet/Xml as the source of the data for the tests. *Supports Sandbox test model, if test will be done in sandbox, all database operations will be rolled back meaning any changes will be undone. *Unique cross-different-type-database testing, which means target and reference result set can come from two databases, even one is SQL Server, another is Oracle.

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.