Frequently Asked Questions
From asmock
What is ASMock?
ASMock's public interface is a modified port of Rhino Mocks by Ayende Rahien (Oren Eini). However, due to the differences in available frameworks for ActionScript, a lot of work had to be done in order to generate dynamic proxies. Additionally, there are a number of API changes due to either keyword restrictions, or semantic differences in ActionScript vs .NET.
ASMock can be used to create mock versions of objects. Expectations can then be set on how that object will be used, such as what value an accessor (property) should return or what arguments you expect to be supplied to a method. This allows components to be tested using controlled inputs so that their outputs can be tested without the test "bleeding" over into another component.
See the Quick Start Guide and the API documentation for more details.
How does ASMock work?
ASMock generates dynamic classes (using bytecode) that extend other classes or implement interfaces and creates an in-memory SWF movieclip. That movieclip is then loaded into the application domain using Loader.loadBytes where the proxy class can then be instantiated.
The generated class overrides (and/or implements) any available (public) methods and notifies the MockRepository that a method call (including accessors/properties) has occurred. The MockRepository then reacts to the method call, depending on whether the mock object is currently recording or replaying.
Can I use ASMock with AIR?
Yes!
Can I use ASMock with Flash?
Flash is not supported yet because Flash CS3 does not support Flex-built SWCs, but I believe CS4 will be adding support. Regardless, unless there are enough requests, ASMock won't be supporting Flash explicitly.
Why does ASMock require asynchronous preparation of mock objects?
This simply comes down to the fact that Loader.loadBytes is asynchronous, with no obvious workaround. As loadBytes is the only known way of injecting dynamic code at runtime, it's simply a limitation that has to be dealt with. However, ASMock integrated with several Unit Testing Frameworks to make things easier for you.
Where can I find documentation for the runtime swf and bytecode generator?
While the code for the bytecode generator is obviously available in the subversion repository as part of the project, I will not be supporting or releasing documentation for it in the short term.
My plan is to separate it into it's own framework (flEmit, hence the package name in the source), but I don't want to do this before making it more feature complete and cleaning up some loose ends. Right now I simply don't have time to work on it since I'm putting all my spare coding time into ASMock.
How can I use ASMock with <my favourite testing framework>?
The ASMock source ships with integration code samples for unit testing frameworks. For more information on which frameworks are supported, see Installation.
Where did you get your beautiful site design (asmock.sourceforge.net)?
As describing my design skills as "poor" would be kind, I "borrowed" the site design from the WiX project. Thanks/sorry guys!
