Accessibility

Table of Contents

Test Driven Development with ColdFusion –
Part 1: Driven by the cold

No fear!

Excessive pressure to deliver can be the demise of software quality, and fear also prevents you from trying something new, possibly faltering along the way, but ultimately succeeding. Take a leap of faith and try unit testing and TDD; we promise you will learn something new and valuable!

Note: TDD implies that the developer writes unit tests as they code; however, you can still write unit tests without practicing TDD. Each developer must decide when to write tests. It has been our experience that one of the most beneficial things you can do for your development process is to write unit tests for your code, as you develop your code. We wouldn't have spent hours upon hours building a freely available test framework and Eclipse plug-in for ColdFusion if we didn't strongly believe this ourselves. Not only are we the tool builders, we are some of its most demanding users!

Terminology

Unit Test: Code that when run, exercises and tests your production code at an atomic level.

Production Code: The code that gets executed when the application is run. This is typically what your customer is paying for.

Test Case: A specific test that executes some production code and checks its state or behavior.

Test Suite: A collection of test cases that can be run together.

Assertions: Functions that test the state of an object. For example, assertEquals(expected value, actual value), assertTrue(boolean expression).

Red-Green-Refactor: The TDD mantra. Red indicates a failing test; Green is a passing test (see Figure 1); and Refactoring is the process of altering the code's implementation.

Baby Steps: Small incremental changes to your code and unit tests.

Note the pretty Green bar. Green is good; it indicates a passing test in MXUnit.

Figure 1. Note the pretty Green bar. Green is good; it indicates a passing test in MXUnit.