2 Replies Latest reply on Oct 11, 2010 5:09 AM by Praveen Kumar Indupuri

    Flex Unit 4 Doesnt wor with AS4 Mock

    Praveen Kumar Indupuri Level 1

      Hi,

      Wehen I run the Mock 4 AS script with the Flex Unit 4 I get the dblow error.

       

       

       

      ArgumentError: Error #1063: Argument count mismatch on org.mock4as.samples.publisher::PublisherTest

      at flexunit.framework::TestSuite(TestSuite.as:124)

      at org.flexunit.internals.runners::FlexUnit1ClassRunner/createTestSuiteWithFilter(FlexUnit1C lassRunner.as:167)

      at org.flexunit.internals.runners::FlexUnit1ClassRunner(FlexUnit1ClassRunner.as:100)

      at org.flexunit.internals.builders::FlexUnit1Builder/runnerForClass(FlexUnit1Builder.as:60)

      at org.flexunit.runners.model::RunnerBuilderBase/safeRunnerForClass(RunnerBuilderBase.as:63)

      at org.flexunit.internals.builders::AllDefaultPossibilitiesBuilder/runnerForClass(AllDefault PossibilitiesBuilder.as:106)

      at org.flexunit.runners.model::RunnerBuilderBase/safeRunnerForClass(RunnerBuilderBase.as:63)

      at org.flexunit.runners.model::RunnerBuilderBase/localRunners(RunnerBuilderBase.as:119)

      at org.flexunit.runners.model::RunnerBuilderBase/runners(RunnerBuilderBase.as:87)

      at org.flexunit.runners::Suite(Suite.as:170)

      at org.flexunit.runner::Request$/classes(Request.as:201)

      at Function/http://adobe.com/AS3/2006/builtin::apply

      at org.flexunit.runner::FlexUnitCore/runClasses(FlexUnitCore.as:191)

      at Function/http://adobe.com/AS3/2006/builtin::apply

      at org.flexunit.runner::FlexUnitCore/run(FlexUnitCore.as:171)

      at flexunit.flexui::FlexUnit4TestRunner/run(FlexUnit4TestRunner.as:75)

      at flexunit.flexui::FlexUnitTestRunnerUI/runWithFlexUnit4Runner(FlexUnitTestRunnerUI.mxml:14 8)

      **[ at FlexUnitApplication/onCreationComplete(FlexUnitApplication.mxml:22) ]

      **[ at FlexUnitApplication/___FlexUnitApplication_Application1_creationComplete(FlexUnitApplicat ion.mxml:7) ]

      at flash.events::EventDispatcher/dispatchEventFunction

      at flash.events::EventDispatcher/dispatchEvent

      at mx.core::UIComponent/dispatchEvent(UIComponent.as:12266)

      at mx.core::UIComponent/set initialized(UIComponent.as:1577)

      at mx.managers::LayoutManager/doPhasedInstantiation(LayoutManager.as:759)

      at mx.managers::LayoutManager/doPhasedInstantiationCallback(LayoutManager.as:1072)

      How can I resolve this error.

        • 1. Re: Flex Unit 4 Doesnt wor with AS4 Mock
          mlabriola Level 4

          i noticed that you error message includes flexunit.framework.testsuite? it also says that you are using the flexunit one runner. this means that your code is extending from testcase and testsuite meaning that, while you are using flexunit four to run these tests, you are still writing flexunit one style tests.

           

          either the flexunit or mockas team may have a bug, but i am not sure if that project is intended to work with flexunit one. can you post a code snippet that shows the issue?

          • 2. Re: Flex Unit 4 Doesnt wor with AS4 Mock
            Praveen Kumar Indupuri Level 1

            Here is code snippet I am using

             

             

            package org.mock4as.samples.publisher

            {

             

             

            import flexunit.framework.TestCase;

             

            import org.mock4as.Mock;

             

                public class PublisherTest extends TestCase

            {

            public function PublisherTest(methodName : String){

                        super(methodName);

                    }

                       

            public function testOneSubscriberReceivesAMessage():void{

            // create the mock

            var mockSubscriber:MockSubscriber = new MockSubscriber();

            const MSG:String = "MESSAGE";

            // set expectations

            mockSubscriber.expects("receive").times(1).withArg(MSG).noReturn();

            // inject the mock

            var myPublisher:Publisher = new Publisher();

            myPublisher.add(mockSubscriber);

            // execute

            myPublisher.publish(MSG);

            // verify mock behavior

            mockSubscriber.verify();

            // show mock expectation error message if any

            assertNull(mockSubscriber.errorMessage());

            }

            }

             

            // Inner Class

            import org.mock4as.Mock;

            import org.mock4as.samples.publisher.ISubscriber;

             

            class MockSubscriber extends Mock implements ISubscriber {

            public function receive(message:String):void

            {

            record("receive", message);

            }

            }