Payday Loans Online Payday Loans Online

Todd Rothe : UI/UX Developer

it's pronounced rowth-ee

By 2g1c2 girls 1 cup

ASMock QuickStart

Mocking objects for tests is standard practice. Recently I had the chance to suport a jr. dev in using FlexUnit 4 and ASMock. Here are the errors she ran into while getting started.

1. ArgumentError: A proxy for com.client.product.models::MyModel has not been prepared yet

At the start of the class you will need the Mock metadata tag with a reference to the class MyModel
[Mock("com.models.MyModel")]
public class PreviewBookViewTest
{ …

2. ArgumentError: A proxy for com.client.product.models::MyModel has not been prepared yet

The [Before] metadata tag was in place

[Before]
public function setUp():void
{
_mockRepo = new MockRepository();
_myModel = _mockRepo.createDynamic(MyModel) as MyModel;
}

but the [RunWith] metadata tag was missing from the start of the class

[Mock("com.models.MyModel")]
[RunWith("asmock.integration.flexunit.ASMockClassRunner")]
public class PreviewViewTest
{ …

more posts at www.toddrothe.com/blog

 

No Responses to “ASMock QuickStart” (post new)

 

Leave a Reply

You must be logged in to post a comment.