Chapter 22. Unit Testing with FlexUnit

Unit testing is a practice and concept that has been gaining in popularity and acceptance in the Flex community as Flex applications have grown larger and more complex. Unit testing, the process of ensuring that new additions or changes to a project do not introduce bugs or modify expected behavior, enables large teams to work in tandem without introducing bugs and confirm that individual parts of a program, down to specific methods, all return the expected results. This pinpoints bugs and errors much more quickly, because a properly written unit test will test the behavior of a very small piece of functionality.

The core of unit testing is the test case, an evaluation that passes a value into a method of an application and reports the test as passing if the correct value is returned. These can be as simple as checking whether a method returns the correct integer value for an operation or as complex as ensuring that some display logic is appropriately performed or that a service has returned the correct object type. A group of test cases that can be used to test an entire application or a specific aspect of a very large application are referred to as a test suite. The test suite will show all test cases that have passed or failed. As a developer adds new code to the application, new test cases are written to provide coverage for that new code and are added to the test suite, and then the entire test suite is run. This ensures that any added ...

Get Flex 4 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.