Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Mockito problems - Please make sure you specified a call to stub in gi

Mockito problems - Please make sure you specified a call to stub in gi

Mockito problems - Please make sure you specified a call to stub in gi

    I'm trying to get a handle on mocking w/ Mockito to and I keeping getting this error:
"Please make sure you specified a call to stub in given".  Also, I cannot get mockito to work unless I add the mock directive
outside the class:



Here's a copy of my code:


package TDMSETestSuites.organWeights.tests
    import common.interfaces.IScaleService;
    import common.services.ScaleService;
    import flash.events.EventDispatcher;
    import flash.utils.Timer;
    import flexunit.framework.Assert;
    import mx.collections.ArrayCollection;
    import mx.rpc.AsyncToken;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.mxml.RemoteObject;
    import mx.rpc.remoting.test.RemoteObjectStub;
    import org.flexunit.async.Async;
    import org.flexunit.async.TestResponder;
    import org.flexunit.rules.IMethodRule;
    import org.hamcrest.core.*;
    import org.mockito.Mockito;
    import org.mockito.integrations.*;
    import org.mockito.integrations.flexunit4.MockitoRule;
    import org.spicefactory.parsley.core.context.Context;
    import org.spicefactory.parsley.dsl.context.ContextBuilder;
    import org.spicefactory.parsley.flex.FlexConfig;
    //so far, this, declaration, at this level is the only way it works- WHY??
    public class ScaleServiceTest extends TDMSETestBase
        public var mockitoRule:IMethodRule = new MockitoRule();//mockito crucial
        public var injectedScaleRemoteObject:RemoteObject;
        public var injectedScaleService:IScaleService;
        public var iScaleService:IScaleService;
        public var scaleService:ScaleService;
        //---- mockito properties --------------------------------
        private var mockScaleService:ScaleService;
        private var mockScaleIService:IScaleService;
        private var mockito:Mockito = new Mockito();

        public var context:Context;
        private var fault:Boolean=Boolean(false);
        private var resultCheckTimer:Timer;

        // The timer and result check timeouts
        private static const TIMEOUT_MS:int = 4000;
        private static const RESULT_CHECK_TIMEOUT_MS:int = 3500;        
        public function setUp():void
            //create base TDMSE parsley context
            context = ContextBuilder.newBuilder()

            scaleService = new ScaleService();
            mockScaleService = mock(ScaleService);
        //---- MOCHITO TESTS ------------------------------------------------------------
        public function mockitoGetScaleData1():void
            var token:AsyncToken = mockScaleService.getScaleData(faultHandler);

here's the service class and method it's testing:


    public class ScaleService extends EventDispatcher implements IScaleService
        public var scaleService:RemoteObject;

        public function getScaleData(getScaleDataFaultHandler:Function):AsyncToken
            return scaleService.getScaleData().addResponder(new AsyncResponder(getScaleData_result, getScaleDataFaultHandler));

I'm completely stumped here and have been googling for days!!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close