ASMock: ActionScript 3 Mocking Framework
Search

Introduction

ASMock ("Ay-Es-Mock" or "Az-Mock") is a dynamic mocking framework for ActionScript 3 (Flex and Flash). ASMock allows you to create fake versions of dependant components (classes and interfaces) so that your unit tests do not end up testing multiple components. Being a dynamic mocking framework means you don't have to do anything to create the mock, the framework creates the object for you at runtime.

Latest news

ASMock 0.9
August 9, 2009

ASMock 0.9 has been released, with some significant updates:

  • FlexUnit 4 now supported (as default)
  • Dynamic mocks and stubs now supported
  • Property stubbing (automatic properties) now supported
  • FlexUnit 1 and fluint 1 integration are now distributed as SWCs
  • Rest and optional arguments now supported on constructors
  • Expectation error messages are now much clearer (though there's still some work to do in this area)

On top of all that, there's a brand new project wiki that includes a whole new quick start guide and integration examples with all the major testing frameworks.

Download ASMock 0.9

ASMock 0.9 Coming Soon
August 3, 2009

ASMock 0.9 is getting closer to release with support for stubs, dynamic mocks, stubbed properties and FlexUnit 4. Integration with FlexUnit 4 is a bit cleaner as it is done entirely through metadata (no base class):

[Mock("mx.graphics.IStroke")]

[RunWith("asmock.flexunit.ASMockClassRunner")]
public class SampleFixture
{
    [Test]
    public function testWeightStub() : void
    {
        var mocker : MockRepository = new MockRepository();
        
        var stroke : IStroke = IStroke(mocker.createStub(IStroke));
	stroke.replay();
        
        stroke.weight = 5;
        
        assertThat(stroke.weight, equals(5));
    }
}
            
ASMock Beta 3
April 24, 2009
A third beta version of ASMock has been released. This release includes bug fixes and a Fluint integration class. Download it now on the downloads page. This release goes out to Adam Creeger (at his request), good luck in the US!
ASMock Beta 3 Coming Soon
February 15, 2009
A third beta version of ASMock is currently in the pipeline, with the major new features being stubs (mocks with auto properties/events) and dynamic mocks (where unrecorded method calls do not throw errors by default). I will also be introducing the record() syntax, used in the same way as ordered/unordered(), for users who like a clear separation of their method recordings (and want to skip the replay(All) method call). To coincide with the release, I will also be adding a Fluint integration class.
ASMock Beta 2
February 15, 2009
A second beta version of ASMock has been released. This version has added support for Vector types and fixes many bugs. There is also a tutorial series that explains how to use the framework.
ASMock Beta 2 Coming Soon
February 9, 2009
I'm getting very close to releasing a new beta (mainly bug fixes). More importantly, though, is that with the new release will be a tutorial series that explains the various features of the framework. Watch this space.
ASMock Beta 1
January 23, 2009
A beta version of ASMock has been released. This version has added support for mocking class, ordered mocks, dispatching events and optional parameters. API Documentation has also been added.

Update (2009-23-01): Re-released beta 1 due to an issue with Adobe AIR
ASMock Alpha 1
January 11, 2009
An alpha version of ASMock as been released. This version only has support for unordered mocks on interfaces and is missing documentation.