Just a little help with flexunit4

46 views
Skip to first unread message

JohnG

unread,
Oct 26, 2010, 10:18:00 AM10/26/10
to mockito-flex
Everyone,

Here's the test I'm trying to get to work.

[RunWith("org.mockito.integrations.flexunit4.MockitoClassRunner")]
public class OrderSubmitControllerTester extends SwizTestCase {

private var controller:OrderSubmitController;

[Mock(type="com.overstock.webdev.checkout.business.ShoppingSiteCommunicator")]
private var mockShoppingSiteCommunicator:ShoppingSiteCommunicator;
[Mock(type="com.overstock.webdev.checkout.model.ApplicationModel")]
private var mockApplicationModel:ApplicationModel;
// private var swiz:Swiz;
// private var swizTestCase:SwizTestCase;

public function OrderSubmitControllerTester() {
super();
}

[Before]
public function setUp():void {
configureSwiz("orderSubmitController");
mockShoppingSiteCommunicator = mock(ShoppingSiteCommunicator);
mockApplicationModel = mock(ApplicationModel);
controller.communicator = mockShoppingSiteCommunicator;
controller.appModel = mockApplicationModel;
}

[After]
public function tearDown():void {
controller = null;
}

[Test(async)]
public function testOrderSubmitWithBypassQas():void {

Everytime I run this I get the following error:

Custom runner class
org.mockito.integrations.flexunit4.MockitoClassRunner cannot be
instantiated
Error: Custom runner class
org.mockito.integrations.flexunit4.MockitoClassRunner cannot be
instantiated
at org.flexunit.internals.runners::InitializationError()[C:\Users
\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit
\FlexUnit4\src\org\flexunit\internals\runners\InitializationError.as:
44]
...

I have mockito-1.4M4 as a dependency and also FlexUnit4-4.0-beta-1

Any ideas? Thanks in advance

JohnG

Kris

unread,
Oct 26, 2010, 11:09:04 AM10/26/10
to mockit...@googlegroups.com
Hi John,

You apparently miss the hard reference to org.mockito.integrations.flexunit4.MockitoClassRunner class, you have only the string reference. So either add it somewhere to make sure it got linked with your application or preferably use MockitoRule instead of runner:



public class OrderSubmitControllerTester extends SwizTestCase { 

     [Rule]
     public mockito:MockitoRule = new MockitoRule();

...

Hope this helps,
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.


JohnG

unread,
Oct 26, 2010, 12:23:49 PM10/26/10
to mockito-flex
Thanks Kris,

A carry-over question related to A Rule. Now that I don't extend
MockitoTestCase, how do I 'prepare' the classes that I want to mock? I
know that I have to call 'Mock' on each, e.g.
mockShoppingSiteCommunicator = mock(ShoppingSiteCommunicator);

but how do I 'prepare' that class first. There is no prepareClasses
call on the mokito variable from the Rule.

Thanks in advance.

JohnG


On Oct 26, 9:09 am, Kris <kris.karczmarc...@gmail.com> wrote:
> Hi John,
>
> You apparently miss the hard reference to
> org.mockito.integrations.flexunit4.MockitoClassRunner class, you have only
> the string reference. So either add it somewhere to make sure it got linked
> with your application or preferably use MockitoRule instead of runner:
>
> public class OrderSubmitControllerTester extends SwizTestCase {
>
>      [Rule]
>      public mockito:MockitoRule = new MockitoRule();
>
> ...
>
> Hope this helps,
> Kris
>
> > mockito-flex...@googlegroups.com<mockito-flex%2Bunsu...@googlegroups.com>
> > .

JohnG

unread,
Oct 26, 2010, 12:31:30 PM10/26/10
to mockito-flex
Kris,

Nevermind on my last message. I found it. I use [Mock] when declaring
the class. Everything works. Thanks a lot!

JohnG

On Oct 26, 9:09 am, Kris <kris.karczmarc...@gmail.com> wrote:
> Hi John,
>
> You apparently miss the hard reference to
> org.mockito.integrations.flexunit4.MockitoClassRunner class, you have only
> the string reference. So either add it somewhere to make sure it got linked
> with your application or preferably use MockitoRule instead of runner:
>
> public class OrderSubmitControllerTester extends SwizTestCase {
>
>      [Rule]
>      public mockito:MockitoRule = new MockitoRule();
>
> ...
>
> Hope this helps,
> Kris
>
> > mockito-flex...@googlegroups.com<mockito-flex%2Bunsu...@googlegroups.com>
> > .

Kris

unread,
Oct 26, 2010, 4:45:17 PM10/26/10
to mockit...@googlegroups.com
Go through this doc: http://bitbucket.org/loomis/mockito-flex/wiki/releases/Release1.3

Once you annotate a public field with [Mock...] it gets prepared and assigned. If you want to assign manually put annotation over the class.

Regards,
Kris
Reply all
Reply to author
Forward
0 new messages