O'Reilly logo

Professional Adobe® Flex® 3 by Joe Berkovitz, David Hassoun, Andrew Trice, Tom Sugden, Todd Prekaski, Jun Heider, Peter Ent, Joseph Balderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 73. Unit Testing and Test-Driven Development with FlexUnit

This chapter covers the practice of unit testing and the best practice of Test-Driven Development (TDD), using FlexUnit, the open-source unit-testing framework for Flex. When practiced together, these techniques are invaluable, helping you to write more robust and better designed software with fewer dependencies and looser coupling between classes. You can catch bugs early, before they can enter production, when the cost of fixing them is much higher.

Overview

Unit testing is the practice of testing the small pieces of functionality that make up an application to ensure that they operate correctly. These small pieces are the units, and they are tested to ensure that each one satisfies its contract by returning the expected results, handling errors appropriately, and collaborating properly with dependent interfaces. If each unit of a system is deemed to be correct, one might infer that the system as a whole is correct. In reality, such a claim would be presumptuous, but unit testing does provide many benefits and reassurances.

TDD is a technique that takes unit testing to its logical extreme, by advocating that unit tests be written first, before the functionality that will actually be tested has even been implemented. Unsurprisingly, the unit test will initially fail, since the functionality has not been written, but when it does succeed, the developer knows that the code is correct. This process can seem back-to-front ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required