Search the web
Sign In
New User? Sign Up
flexcoders · RIA Development with Adobe Flex
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Mock objects in AS3   Message List  
Reply | Forward Message #97840 of 149659 |
Re: [flexcoders] Re: Mock objects in AS3

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.

cheers,
Drew



Wed Jan 2, 2008 11:11 am

lists@...
Send Email Send Email

Forward
Message #97840 of 149659 |
Expand Messages Author Sort by Date

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...
aduston1976
Offline Send Email
Oct 17, 2007
3:06 am

try add flash.net.registerClassAlias( "attempt.TestInterface", TestInterface ); prior to your cast attempt. regards, Bjorn...
Bjorn Schultheiss
bjorn.schult...
Offline Send Email
Oct 17, 2007
3:13 am

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. ...
Christophe Herreman
herrodius
Offline Send Email
Oct 17, 2007
7:53 am

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()...
dave_defusion
Offline Send Email
Oct 18, 2007
12:40 pm

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 Schultheiss
bjorn.schult...
Offline Send Email
Oct 18, 2007
11:01 pm

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...
aduston1976
Offline Send Email
Oct 19, 2007
2:44 am

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...
aduston1976
Offline Send Email
Dec 26, 2007
2:44 am

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 ...
Christophe Herreman
herrodius
Offline Send Email
Dec 26, 2007
9:06 am

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...
yigit
yigitboyar
Online Now Send Email
Dec 26, 2007
9:50 am

... 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...
Frederico Garcia
fmotagarcia
Offline Send Email
Dec 26, 2007
12:11 pm

I guess that your solution has a problem, the circular reference to toString. it could be something like: [Bindable] public var stringValue:String = ""; public...
Jhonny Everson
khronnuz
Offline Send Email
Dec 26, 2007
2:13 pm

... 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...
Frederico Garcia
fmotagarcia
Offline Send Email
Dec 26, 2007
3:38 pm

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...
Kevin
jeff_lacer
Offline Send Email
Dec 27, 2007
4:35 am

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...
yigit
yigitboyar
Online Now Send Email
Dec 27, 2007
7:41 am

... Hi, Functions are indeed bindable, but only special function are: getters and setters. If you look carefully in the help topic you siggested the ... ...
Frederico Garcia
fmotagarcia
Offline Send Email
Dec 27, 2007
12:57 pm

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...
yigit
yigitboyar
Online Now Send Email
Dec 28, 2007
2:35 pm

... 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...
Kevin
jeff_lacer
Offline Send Email
Dec 29, 2007
4:32 pm

... 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...
Frederico Garcia
fmotagarcia
Offline Send Email
Dec 29, 2007
4:56 pm

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@...
Send Email
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 Halm
spicefactory...
Offline Send Email
Dec 26, 2007
3:36 pm

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,...
aduston1976
Offline Send Email
Dec 26, 2007
10:51 pm

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...
aduston1976
Offline Send Email
Dec 30, 2007
8:29 pm

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@...
Send Email
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...
Christophe Herreman
herrodius
Offline Send Email
Jan 3, 2008
10:53 am

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@...
Send Email
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...
abdulqabiz3
Online Now Send Email
Jan 4, 2008
11:51 am

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...
aduston1976
Offline Send Email
Jan 6, 2008
5:09 am

Hi all, has anyone made any progress on this? regards, Christophe ... -- Christophe Herreman http://www.herrodius.com http://www.pranaframework.org...
Christophe Herreman
herrodius
Offline Send Email
Jan 28, 2008
8:06 am

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...
Josh McDonald
brucethebruiser
Offline Send Email
May 30, 2008
9:16 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help