As the author of that mock framework Adam linked to I thought I
should chip in with my thoughts on the issues that have been raised.
Regarding having to hand code the implementation of the class you
want to mock I have found that with a couple of snippet templates for
TextMate I can write them quite quickly.
If you are going to hand-code stubs for use in testing without using
a framework you are adding behaviour to a class which means you
should then be testing that class too.
To ease some of the pain until we can generate mock objects from
interfaces I intend to bundle a bunch of support classes that provide
mocks for many of the core flash class (think URLLoader,
EventDispatcher, Socket, etc). Speak up if you've got suggestions for
the classes you would like to see included initially.
I have a couple of ideas about what we would need to be able to
generate the mock classes:
1) Generate the .as for the mock from reflection information at
runtime, then compile the generated .as at runtime with a self-hosted
compiler (AS3 compiler in AS3) then load it via Loader.loadBytes and
flash.utils.getDefinitionByName
2) Write an AS3 Parser in something like Java or Ruby that would
provide access to the Abstract Syntax Tree from which we can generate
the mock class, then compile the generated .as with mxmlc along with
the test suite.
By implementing a tool that provides the AST for an AS3 class we open
up the doors for lots of fun like generating mocks, AOP, code
mutation (think adding hooks for code coverage reporting, mutation
testing, additional metadata directives)
There is work in the Tamarin project for a self-hosted compiler
however last I checked it wasn't far enough along for our purposes.
The hxASM library looks interesting and could definately be an avenue
worth exploring for this. Adam, I would be interested in
collaborating on getting a port of hxASM to AS3 so that we can
generate the necessary bytecodes to create mocks from an interface at
runtime.
lus I see a number of places on the web where the idea is mentioned, e.g. http://www.herrodius.com/blog/?m=200704 . However I cannot find any mock frameworks...
Hi guys, I started looking at the EasyMock framework but haven't had the time yet to play around with this in Prana. I would be very interested in doing so. ...
Bjorn, I have been looking at this (as I would like a mocking framework for Flex too) this evening and I've had no luck either. The the registerClassAlias()...
Hey Dave and Adam, That way a quick reply i sent yesterday without much thought. Currently to convert a generic object to a typed instance i've been using a...
Bjorn, I think this is a hack but it looks like a pretty awesome hack and I'm definitely going to use it. Thank you very much for posting it! I think this is...
I started a new project recently and came to a point in testing where I was writing a bunch of custom mock objects. Great place, I thought, to pick up my dream...
Hi Adam, I have also been looking into runtime interface implementation to create Mock objects and a basic AOP framework. I'm stuck at the exact same thing as ...
hi all; i have a custom class which has a toString method; so i can directly use it as a source to textInput's text field. i want to make binding work, i mean...
... I believe you can only bind vars and setters. By binding a function i think it will only execute the function once. An easy workaround is to have a var...
I guess that your solution has a problem, the circular reference to toString. it could be something like: [Bindable] public var stringValue:String = ""; public...
... Yes, indeed there was a circular reference to toString. Thanks for the correction. The general concept is the same though, and I think it's the best way to...
Binding to getters or read-only functions is tricky. I haven't found a really elegant OOP approach, although others have offered solutions like dispatching...
i think i'm misunderstood; because your solution suggestions does not fit my problem. first of all, functions can be binded. (with an event driven architecture...
... Hi, Functions are indeed bindable, but only special function are: getters and setters. If you look carefully in the help topic you siggested the ... ...
http://127.0.0.1:49661/help/index.jsp?topic=/com.adobe.flexbuilder.help/html/databinding_4.html here; in the first example, there is a bindable function and it...
... are you sure about that? I could be wrong, but I would guess that if you add a button under the TextInput tag your TextInput text value will not update as...
... Thanks Kevin, Great post on function binding. I believe function binding is quite cool, BUT troublesome and needless. Binding a property to a function with...
override the set data function in your item renderer and bind your function getter to an event you dispatch in there. ... -- j:pn \\no comment...
Johannes Nel
johannes.nel@...
Dec 28, 2007 3:18 pm
... I think we should turn that into a feature request for a future Flash Player. Of course you can start a project for a bytecode manipulation framework, but...
Jens: Indeed, we need Proxy#newProxyInstance in AS. This is how EasyMock creates its mocks. There is an equivalent mechanism in c# that is used by Rhino Mocks,...
I played with hxasm for about 1.5 hours today. Although I didn't succeed, I have seen enough to know that it is completely possible to dynamically generate...
As the author of that mock framework Adam linked to I thought I should chip in with my thoughts on the issues that have been raised. Regarding having to hand...
Drew Bourne
lists@...
Jan 2, 2008 10:55 pm
Hi Drew, just FYI: Adam and I talked about this some days ago. I pointed him to the fact that you could easily convert the Haxe code to AS3 using a flag for...
Hi Christophe, Ohh neatness! Thanks for the heads up, I had no idea Haxe had that feature. I'm going to spend some time on this tonight & tomorrow. cheers, ...
Drew Bourne
lists@...
Jan 3, 2008 1:38 pm
I heard of reading, in this thread, about ActionScript compiler in ActionScript. Metal Hurlant has created a library (eval) which is still being developed, but...
Hi, Sorry for being out of the conversation for a few days. I ran into a problem while trying to do this using hxasm. If I write out the bytecode for a class...
Hey guys, I'm really interested in this stuff as well, if there's an off-list discussion going on, can I get in on it? :) Cheers, -Josh On Mon, Jan 28, 2008 at...