Menu

test_driven_development

Katherine E. Lightsey

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards. Kent Beck, who is credited with having developed or 'rediscovered' the technique, stated in 2003 that TDD encourages simple designs and inspires confidence.

I am a huge fan of Wiki the online free encyclopedia, and frequently reference it to support work that I do. Imagine my dismay when I went to the page on Unit Testing and found not a single mention of the SQL Language! For Test Driven Development, again not a single mention of SQL! As I am an avid proponent of both Unit Testing and Test Driven Development and my favorite language is SQL, or Structured Query Language if you prefer, I find this to be a grave error and seek to redress it here.

There are two core requirements of TDD; a programmatic unit test which serves both as requirements for development and as an auditing tool for operations, and code refactoring at will for reasons of performance, compliance to standards, or extension of functionality.

TDD is an Agile methodology. It seeks to avoid the big design up front problem by building software in discrete parts rather than as a whole. In the words of the Agile Manifesto:
- Customer satisfaction by rapid delivery of useful software
- Welcome changing requirements, even late in development
- Working software is delivered frequently (weeks rather than months)
- Working software is the principal measure of progress
- Sustainable development, able to maintain a constant pace
- Close, daily cooperation between business people and developers
- Face-to-face conversation is the best form of communication (co-location)
- Projects are built around motivated individuals, who should be trusted
- Continuous attention to technical excellence and good design
- Simplicity—the art of maximizing the amount of work not done—is essential
- Self-organizing teams
- Regular adaptation to changing circumstances

A unit test is a method which programmatically tests the execution of another program, testing either individual cases for the target method or a batch of cases as a "test suite". Unit tests are designed to test both primary and boundary conditions of the target method as well as both the business functionality of an object and the system functionality (non-business exposed) of an object. Unit tests can be both white box and black box methods and can be run during code promotion or in regression. A unit test or suite of tests are required in order to use TDD as a development process.

Code refactoring is the process of rewriting code to improve its performance, bring it up to standards such as object naming, or to extend its functionality. Any developer must be allowed to make any changes (that meet shop standards) to an object at any time as long as the object still meets its associated unit test(s). This may be further down the line during original development, such as in peer review, or it may be long after deployment to add functionality or improve performance. Code refactoring is a core component of the Agile methodology, being required to meet the tenets of simplicity and adaptation.

[test_driven_development_example]


copyright Katherine Elizabeth Lightsey 1959-2013 (aka; my life)

"Don't give me songs; give me something to sing about! Buffy the Vampire Slayer


Related

Wiki: Home
Wiki: test_driven_development_example
Wiki: unit_test

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.
Try Free →