Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Testing Flex/Flash Libraries in FlashBuilder

For a normal Flash/Flex application I would include my Unit Tests in my application project (perhaps in a tests source folder alongside my main src folder). I'd then have two application entry points: the app, and it's tests.

How are people doing this for their Flex Library Projects? You know, the kind that produces a SWC file. As far as I can tell, you can't set an executable entry-point for these projects (to run the tests).

like image 496
darscan Avatar asked Feb 05 '26 00:02

darscan


1 Answers

Normally, Flash Builder only allows you to use the debugger from a Flex/AIR application, not a library project. So best thing to do here is load the library into a Flex application and write+debug tests there.

Here are step-by-step instructions to be able to test your library project, with debugging/stepping enabled:

  1. Create a Flex Library project that you want to test + debug
  2. Create a normal, empty Flex Application. We will write the tests in this dummy Flex Application so we can utilise the debugging features.
  3. Set the library's build-path to the 'libs' folder of the Flex Application so it builds most recent code into a swc loaded by the Flex Application.

  4. Optionally, set the Flex Application to 'reference' the library project in Project Properties->Project References, this ensures the library code is built first.

  5. Write your tests in the Flex Application
  6. Debug and run your tests: you should be able to step through your library source code! Nice.
  7. Optionally, once you're satisfied your tests are all good copy your tests back into the library project to keep all the library's associated code together in one project. Make sure you're not including the test classes in the actual library swc.

This is how I do it anyway.

like image 148
timoxley Avatar answered Feb 08 '26 01:02

timoxley