3

I'm using AsUnit for unit-testing my current AS3 project. My Main() is basically:

if ( UnitTest ) 
    runUnitTests();
else
    runMainProgram();

where I change UnitTest before building depending on whether I want to run the program or run the unit tests. Is there a way that makes it easier to switch between the two modes?

Optimally, I'd use F5 for building with UnitTest=false and another hotkey for building with UnitTest=false. What is the closest I can get with FlashDevelop?

Tim
  • 13,904
  • 10
  • 69
  • 101

4 Answers4

2

You can do the following in FlashDevelop

        if(CONFIG::debug) {
            trace("Debug");
        }  else if(CONFIG::release) {
            trace("Release");
        }

These correspond to the drop down in the toolbar next to the play button.

See this link: http://www.flashdevelop.org/wikidocs/index.php?title=AS3_Conditional_Compilation

In terms of the shortcut, just create a macro that switches the release mode then hits play. From there you can add any shortcut you would like to your macro. So one shortcut will launch the course into debug/release mode as required.

Also note, you can have other CONFIG::bla's - so you might want to have CONFIG:unit1, CONFIG:unit2, etc, etc. See above link.

Chris
  • 54,599
  • 30
  • 149
  • 186
  • Using the debug/release distinction isn't really an option, since the release version has some side-effects such as disabling `trace` output. Is it possible to add another "build version" or change the CONFIG::blas through macros? – Tim Aug 16 '11 at 15:15
  • The macro's probably won't help there. But you can use UNIT_TEST::unit,1 and change the '1' to a '2', or '3' etc from within the project properties. Sadly there isn't a shortcut to it. – Chris Aug 17 '11 at 09:36
  • Chris, there's a flashdevelop plugin for changing those constants called Config::Toggle. That might help. – Gigggas Jan 06 '14 at 00:50
  • @Gigggas Cool, good find. I haven't used flash develop in a long while (I answered the above question a few years ago) – Chris Jan 06 '14 at 03:00
1

Easy solution:

  • duplicate the FlashDevelop project file (.as3proj) and name it "MyProject_tests.as3proj",
  • open this project, create a new ProjectTests class and set it as the main class,
  • change the output SWF in project settings.
Philippe
  • 2,621
  • 1
  • 19
  • 20
0

Add another project file. To run the test using it as the primary. "Document class" the context menu on the file.

0

Like Chris mentioned, you can use FlashDevelop's Compiler Constants to do what you need, though it is a bit cumbersome turning these constants on and off.

However, there is a FlashDevelop plugin called Config::Toggle that makes that significantly quicker by providing an additional panel where you can enable/disable boolean constants with 1 click. The linked website describes the value of the plugin far better than I ever could. Hope that helps.

Gigggas
  • 315
  • 1
  • 6