Test Driven Development (TDD) is an Agile development process which improves the overall design, quality and maintainability of software. At it’s simplest, TDD is the practice of: 1) writing a small test, 2) checking that it fails, 3) writing just enough code to make it pass, 4) improving the design of the code and then, 5) starting over by writing the next test. This is sometimes referred to as the test-code-refactor cycle. It provides the ability to define requirements without vagueness, the ability to design software so that it is decoupled and flexible, and a framework for writing well tested code.
However, practitioners must understand that TDD does not solve all development problems and therefore should be implemented within a framework of supporting processes. TDD additionally affects the development process while gathering requirements, checking-in source code, creating software packages for deployment, testing the software, and deploying software to production.
Development teams often run into common problems when they first attempt to implement TDD in the database. Teams are more successful when they have an experienced coach to help them through the challenges. Among the challenges most often experienced are:
- Creating test data in a way that is flexible and maintainable
- Keeping test cases independent of one another
- Dealing with database constraints such as checks and foreign keys
- Keeping code clean, testable and fast
- Knowing the limits of TDD and the supporting skills to make it work
- Avoiding defaulting back to non-TDD practices when the pressure to deliver rises
- Understanding how to get started with TDD when software already exists
- Fitting TDD into the overall development process, especially in terms of its affects on requirements elicitation and quality assurance
- Implementing and testing data migrations
These challenges are surmountable. We have been there and have helped teams succeed.