Using mockito-flex with spring-actionsript

11 views
Skip to first unread message

LT

unread,
Nov 16, 2010, 7:42:15 PM11/16/10
to mockito-flex
Hi, all.
I'm looking for suggestions about how to mock a class used in an
application that relies on spring-actionscript for instantiation and
dependency management.
Thanks much.
Julian

Kris

unread,
Nov 17, 2010, 4:19:14 AM11/17/10
to mockit...@googlegroups.com
Not sure what's different in this case from any other. Could you be more specific about your problem?

Regards,
Kris

Charles Lee

unread,
Nov 17, 2010, 5:53:44 AM11/17/10
to mockit...@googlegroups.com

You have a interface with that class ? If so mock that

> --
> You received this message because you are subscribed to the Google Groups "mockito-flex" group.
> To post to this group, send email to mockit...@googlegroups.com.
> To unsubscribe from this group, send email to mockito-flex...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mockito-flex?hl=en.
>

Kris

unread,
Nov 17, 2010, 9:25:57 AM11/17/10
to mockit...@googlegroups.com
Reminder: Mockito mocks both interfaces and concrete classes.

LT

unread,
Nov 17, 2010, 2:38:51 PM11/17/10
to mockito-flex
What I'm unsure of is how to ensure that dependencies are resolved
using an instance of the mocked interface, when my spring-actionscript
context xml refers to concrete classes. Since mocking is done at
runtime, how do I get spring-actionscript to use the resulting mock,
not the class being mocked. In other words, in this case, what would
my spring-actionscript context xml look like? (Btw, I've also posted
this question on the spring-actionscript forums.)

On Nov 17, 6:25 am, Kris <kris.karczmarc...@gmail.com> wrote:
> Reminder: Mockito mocks both interfaces and concrete classes.
>
>
>
>
>
>
>
> On Wed, Nov 17, 2010 at 11:53 AM, Charles Lee <charle...@gmail.com> wrote:
> > You have a interface with that class ? If so mock that
> > On 17 Nov 2010 09:19, "Kris" <kris.karczmarc...@gmail.com> wrote:
> > > Not sure what's different in this case from any other. Could you be more
> > > specific about your problem?
>
> > > Regards,
> > > Kris
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "mockito-flex" group.
> > > To post to this group, send email to mockit...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > mockito-flex...@googlegroups.com<mockito-flex%2Bunsubscribe@google groups.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/mockito-flex?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mockito-flex" group.
> > To post to this group, send email to mockit...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mockito-flex...@googlegroups.com<mockito-flex%2Bunsubscribe@google groups.com>
> > .

Kris

unread,
Nov 17, 2010, 2:58:23 PM11/17/10
to mockit...@googlegroups.com
Using IoC ensures that the dependencies are provided externally to the entities. I assume the class you are testing requires several external dependencies and some of them you want to mock. I'd create all needed stuff and assign manually in the test - if you are unit testing.

I assume you want to run more of a functional/integration style of test where you have everything real except say the service endpoints. I'm not familiar with spring-actionscript, but in projects I was working on we were able to replace beans with mocks in contexts before initializing and autowiring the context itself.

The algorithm is:

1) create new instance of a context
2) create mock replacements
3) replace beans with mocks
4) run context initialization

I think you should get closer with the spring-action script guys. I know they were using mockito for testing and may have some better idea.

Regards,
Kris





Charles Lee

unread,
Nov 17, 2010, 3:18:23 PM11/17/10
to mockit...@googlegroups.com
So I think is down to your definition of unit tests, which is what mocking is a technique to serve. The rule of thumb in a IOC environment. If you need to use a manage bean to run your SUT. It no longer is a unit test as it is 'integrate'd with another SUT.

Solution for this is to change your code so the dependency of your other manage bean can be mocked.

C



Regards,
Kris





--
You received this message because you are subscribed to the Google Groups "mockito-flex" group.
To post to this group, send email to mockit...@googlegroups.com.
To unsubscribe from this group, send email to mockito-flex...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/mockito-flex?hl=en.

LT

unread,
Nov 17, 2010, 4:29:11 PM11/17/10
to mockito-flex
Thanks, Kris.
This is exactly what I'm trying to do.

LT

unread,
Nov 18, 2010, 12:49:12 PM11/18/10
to mockito-flex
Got this response from Roland over at SpringActionscript:
http://forum.springsource.org/showpost.php?p=330286&postcount=3
He says they use ASMock, not Mockito for SpringAS, and suggests I use
that instead. I'm going to do a bit more digging around in the
SpringAS source and see if there's some way to do what I need. I now
realize though that I'm in uncharted territory. Oh well...

Kris

unread,
Nov 18, 2010, 1:45:10 PM11/18/10
to mockit...@googlegroups.com
I see - at some point they had couple of question about mockito I thought they were using it.

Anyway if they have support for asmock and you are ok using asmock style than go ahead.

But - if it's possible to use asmock then it's possible to use mockito.

Regards,
Kris

Charles Lee

unread,
Nov 19, 2010, 4:44:19 AM11/19/10
to mockit...@googlegroups.com
And mockito is so much more expressive then asmock ;)

C


Regards,
Kris

--
You received this message because you are subscribed to the Google Groups "mockito-flex" group.
To post to this group, send email to mockit...@googlegroups.com.
To unsubscribe from this group, send email to mockito-flex...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/mockito-flex?hl=en.
Reply all
Reply to author
Forward
0 new messages