Quantcast
Channel: Adobe Community : Popular Discussions - FlexUnit
Viewing all articles
Browse latest Browse all 25673

How to use SequenceRunner with FlexUnit 4

$
0
0

Hi,

 

I just read the Wiki page about Fluint Sequences at http://docs.flexunit.org/index.php?title=Sequences#Sequences_from_Flui nt. I really would like to use sequences as it seems a great way to test flows in UI components.

 

So I created a first test based on the examples in the wiki. Unfortunately it does not work as I hoped.

 

The testcase:

 

package flex.filter.eventFilter.view
{

      import flash.events.Event;

     import mx.events.FlexEvent;

  import net.digitalprimates.fluint.tests.TestCase;

  import org.fluint.sequence.SequenceRunner;
  import org.fluint.sequence.SequenceSetter;
  import org.fluint.sequence.SequenceWaiter;


  public class RelativeDateInputFluintSequence extends TestCase
  {

    private var form:RelativeDateInput;

    [Before(async)]
    override protected function setUp():void
    {
      form = new RelativeDateInput();
      form.addEventListener(FlexEvent.CREATION_COMPLETE, asyncHandler (pendUntilComplete, 100), false, 0, true);
      addChild(form);
    }


    [After(async)]
    override protected function tearDown():void
    {
      removeChild(form);
      form = null;
    }

    [Test(async)]
    public function testForm():void
    {
      var passThroughData:Object = new Object();
      passThroughData.value = 5;
      passThroughData.selectedUnit = "hours";

      var sequence:SequenceRunner = new SequenceRunner(this);

      // Set time in stepper
      sequence.addStep (new SequenceSetter(form.timeStepper, {value:passThroughData.value}));
      sequence.addStep(new SequenceWaiter(form.timeStepper, FlexEvent.VALUE_COMMIT, 100));

      // Set units
      sequence.addStep (new SequenceSetter(form.unitCombo, {selectedItem:passThroughData.selectedUnit}));
      sequence.addStep(new SequenceWaiter(form.timeStepper, FlexEvent.VALUE_COMMIT, 100));

      sequence.addAssertHandler(handleFiveHoursSet, passThroughData);

      sequence.run();
    }


    private function handleFiveHoursSet(event:Event, passThroughData:Object):void
    {
      assertEquals(passThroughData.value * 60 * 60000, form.milliseconds);
    }
  }
}

 

Note that I did not add the test annotations at first as they were ommitted in the Wiki. I added these later after I got the error below.

 

When sequence.run() is executed I get this error:

Cannot add asynchronous functionality to methods defined by Test,Before or After that are not marked async
Error: Cannot add asynchronous functionality to methods defined by Test,Before or After that are not marked async
    at org.flexunit.async::AsyncLocator$/getCallableForTest()[C:\Users\dmoor e\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\flexunit\async\AsyncLocator.as:82]
    at org.fluint.sequence::SequenceWaiter/setupListeners()[C:\Users\dmoore\ Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\fluint\sequence\SequenceWaiter.as:100]
    at org.fluint.sequence::SequenceRunner/continueSequence()[C:\Users\dmoor e\Documents\_Production\Flex Unit 4\GIT\FlexUnit4\src\org\fluint\sequence\SequenceRunner.as:177]
    at org.fluint.sequence::SequenceRunner/run()[C:\Users\dmoore\Documents\_ Production\Flex Unit 4\GIT\FlexUnit4\src\org\fluint\sequence\SequenceRunner.as:124]
    at com.hp.opr.flex.filter.eventFilter.view::RelativeDateInputFluintSeque nce/testForm()[/home/cschlipf/data/dev/svn/opr/components/common/flex/ lib/opr-fx-common/src/test/flex/com/hp/opr/flex/filter/eventFilter/vie w/RelativeDateInputFluintSequence.as:56]
    at net.digitalprimates.fluint.tests::TestCase/protect()[C:\Users\mlabrio la\Documents\workspaces\net\digitalprimates\opensource\flexunit\fluint \fluint\src\main\flex\net\digitalprimates\fluint\tests\TestCase.as:315 ]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at net.digitalprimates.fluint.tests::TestCase/executeMethodWhileProtecte d()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\openso urce\flexunit\fluint\fluint\src\main\flex\net\digitalprimates\fluint\t ests\TestCase.as:370]
    at net.digitalprimates.fluint.tests::TestCase/runTestMethod()[C:\Users\m labriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\ fluint\fluint\src\main\flex\net\digitalprimates\fluint\tests\TestCase. as:160]
    at net.digitalprimates.fluint.ui::TestRunner/runTestMethod()[C:\Users\ml abriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\f luint\fluint\src\main\flex\net\digitalprimates\fluint\ui\TestRunner.as :361]
    at net.digitalprimates.fluint.ui::TestRunner/handleTestProcess()[C:\User s\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexun it\fluint\fluint\src\main\flex\net\digitalprimates\fluint\ui\TestRunne r.as:393]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at net.digitalprimates.fluint.tests::TestCase/handleAsyncEventFired()[C: \Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\f lexunit\fluint\fluint\src\main\flex\net\digitalprimates\fluint\tests\T estCase.as:267]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at net.digitalprimates.fluint.async::AsyncHandler/handleEvent()[C:\Users \mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexuni t\fluint\fluint\src\main\flex\net\digitalprimates\fluint\async\AsyncHa ndler.as:166]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.5.0\frameworks\pr ojects\framework\src\mx\core\UIComponent.as:9440]
    at mx.core::UIComponent/set initialized()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx \core\UIComponent.as:1168]
    at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.5.0 \frameworks\projects\framework\src\mx\managers\LayoutManager.as:718]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.5.0\framew orks\projects\framework\src\mx\core\UIComponent.as:8744]
    at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.5.0\framewo rks\projects\framework\src\mx\core\UIComponent.as:8684]

 

So my guess is that the SequenceRunner is not fully compatible with FlexUnit 4 as asyncronous calls that are internal to the SequenceRunner are not marked as async.

 

Best regards,

Carsten


Viewing all articles
Browse latest Browse all 25673

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>