Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

22. Unit Testing with FlexUnit

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 code does not interfere with previously functional code and that the new code integrates as expected with the application. In the previous version of FlexUnit, the test cases extended a class called TestCase and the test suites were TestSuite instances. All test method names needed to begin with test to be picked up by the unit test runner. In FlexUnit 4, test cases and suites can be of any type and have any names you like. Metadata tags are used to mark tests within a test case and suites of tests: you include the tag [Test] above a test to be run and [Suite] to mark a suite of tests.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint