Presenting at the September Adogo/ORUG meeting

Brian LeGros | September 3rd, 2009 | news  

I will be presenting on Flex, Rails, and RubyAMF with Jake Swanner at the September 10th Adogo meeting. What’s great about this meeting this month, is that we’re pairing up with the ORUG and having a joint meeting, so this audience will hopefully be a good mix of Ruby and Flex developers. Jake’s been busting ass on the Rails side of things, so I think the presentation is gonna go great. If you’re in town on that Thursday and feel like taking in some Ruby and Flex love, stop by Devry at Millenia at 7:00 PM, Room 114. We will also be using Connect to broadcast the presentation, so if you’re interested in attending remotely, just let me know and I’ll try to get you a couple URLs for the meeting. I’m sure, as is our usual pre-Adogo tradition, we will be meeting at BJ’s Brewhouse for beers around 6:00 PM. Hope you can make it out.

Custom test runner for FlexUnit 4 and mock-as3

Brian LeGros | August 6th, 2009 | programming  

At the August Adogo meeting, I presented on the new features coming in FlexUnit4 and mock-as3. During the presentation, I showed the following sample (which has been updated) of how a FlexUnit 4 test using a customer runner for mock-as3 would work. Please keep in mind the example is a bit contrive but exemplifies the configuration options for the runner.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package us.adogo.mock
{
   import com.anywebcam.mock.Mockery;
 
   import org.flexunit.Assert;
   import org.flexunit.assertThat;
   import org.hamcrest.core.not;
   import org.hamcrest.object.equalTo;
   import org.hamcrest.object.hasProperty;
   import org.hamcrest.object.nullValue;
 
   [RunWith("com.anywebcam.mock.runner.MockAs3TestRunner")]
   public class ExampleUsingMockAs3Runner {
      public var mockery : Mockery;
 
      [Mock]
      public var user : User;
 
      [Mock(inject="false")]
      public var account : Account;
 
      private var controller : UserController; 
 
      [Before]
      public function setUp() : void {
         account = mockery.nice(Account, ["1234567890"]) as Account;
         this.controller = new UserController(); 
      }
 
      [Test]
      public function testAddUserWithUsernameAndPasswordOnly() : void {
         //setup mock
         mockery.mock(user).method("save").calls(function () : void {
            user.id = 1;
         }).once;
 
         //populate object properties as you usually would
         user.username = "bobdobbs";
         user.password = "mysecret";
 
         //execute my controller method being tested
         controller.addUser(user);
 
         //test that the currentUsers went up by one and that its id is 1
         assertThat(controller.currentUsers.length, equalTo(1));
         assertThat(controller.currentUsers.getItemAt(0).id, equalTo(1));
         assertThat(controller.currentUsers.getItemAt(0).username, equalTo("bobdobbs"));
         assertThat(controller.currentUsers.getItemAt(0).password, equalTo("mysecret"));
      }
 
      [Test]
      public function testValidateUserAccount() : void {
         //setup mock
         mockery.mock(account).method("isValid").withArgs(User).returns(true).once;
 
         //execute my controller method being tested
         var expected : Boolean = controller.validateUser(new User(), account);
 
         //test that the account is valid
         Assert.assertTrue(expected);
      }
 
      [Test(verify="false")]
      public function testDefaultUserSize() : void {
         assertThat(controller, hasProperty("currentUsers"));
         assertThat(controller.currentUsers, not(nullValue()));
         assertThat(controller.currentUsers.length, equalTo(0));
      }
   }
}

This evening I updated the Adogo SVN with a working version of this runner and thought I’d detail its initial implementation.

  • To use the runner place the metadata [RunWith("com.anywebcam.mock.runner.MockAs3TestRunner")] on the test class’ declaration.
  • Once annotated with metadata, the test class will not run unless a public variable, or setter, is available of type com.anywebcam.mock.Mockery. This will allow the runner to inject a Mockery object and prepare() the mockery to produce mock objects. Using and preparing a mockery is a new requirement for mock-as3 if you’re utilizing type-safe mocks due to the asmock integration.
  • Any public variable, or setter, annotated with the metadata [Mock] will have a type safe version of it injected automatically prior to the execution of each test method. By default a nice mock will be used, but if you specify the “type” attribute (e.g. – [Mock(type="strict")]) as “strict” then a strict mock will then be used. The difference between nice and strict mocks, is the equivalent of the “ignoreMissing” constructor argument on com.anywebcam.mock.Mock being set to true, or false, respectively.
  • If the [Mock] metadata is used on a class with a constructor requiring arguments, whether they are optional or …rest, the runner cannot automatically inject the mock due to a limitation in its underlying dependency on the asmock library. If you need a mock object instance using constructor arguments, set the attribute “inject” as false (e.g. – [Mock(inject="false")]. Doing so will tell the runner that you’re going to use the mock-as3 framework directly to create the mock. The ideal place to do this in your test is within the [Before] methods defined for the test class. By going through all this hoopla, you get automatic mock prepration and verification, just as with the automatically injected mock objects.
  • After the execution of each test method, the runner will automatically call verify() on each object variable/property marked with the [Mock] metadata. If you’d like to disable verify() from being called on all mocks for a test method, simply add the attribute “verify”, with a value of false, to your [Test] metadata (e.g. – [Test(verify="false")]). This can be helpful if you want the runner to inject the mockery and all of your mocks, but you would like to specify which mocks are verified for the test.
  • Currently this runner requires FlexUnit 4 Beta 2 and a custom build of mock-as3 to work as stated. You can find SWCs for each in the Adogo August project linked above.

What’s important to note, is that this runner is more restrictive than using the mock-as3 framework directly, so it may not suite your needs. I based this runner off of concepts I saw in the JMock runner for JUnit 4, the @Mock annotation found in Mockito for Java, and my own testing practices. If anyone finds time to play with it and you find any gremlins, let me know. In speaking with Drew, it looks like this may make it into the next release of mock-as3 along with a couple of other cool features, so I hope people find it helpful.

UPDATE: Drew has been kind enough to deploy this FU4 test runner to the mock-as3 SVN repository under the class name com.anywebcam.mock.runner.MockRunner. Please use this copy for future reference. Please also note this version will only work with FlexUnit4 Beta2 and earlier. FlexUnit4 RC1 has changed the implementation for test runners and this code will need to be updated.

August Adogo meeting preso finished up

Brian LeGros | August 4th, 2009 | news, programming  

Well I gave my hastely assembled and zero practiced version of a FlexUnit4 and mock-as3 presentation last night at the Adogo and I only caught a few people snoozing, so that is a +1 in my book. Unit testing can be extremely dry for most people, but building tools to make me more productive always holds my interest so that’s how I’ll explain my enthusiasm. Thanks to Drew Bourne and Michael Labriola for the help with the presentation. I blubbered through most of the points on their APIs and definitely mispoke on a few instances, but as long as the recording doesn’t get too much traffic we should be fine. Thanks as well to Russ, Vincent, Brian, and Greg for keeping me company after the meeting over a few beers while I waited for my wife’s flight to get in.

I’ve published the source and recording for anyone who is interested.

Adogo Meeting Monday

Brian LeGros | July 28th, 2009 | news  

I’m going to be presenting at this Monday’s (08/03/2009) August Adogo meeting after a few month hiatus due to the new baby. I’ll be running through the new features in FlexUnit4 and some work I’m doing with Drew on mock-as3. Afterwards, we are going to have a group discussion on “Uses for RIAs” where we’ll try to talk about where RIAs are applicable and how they can be abused. If you’re interested in testing in Flex or developer discussion, come by and see the latest and greatest coming out of the community. We have a sponsor for the meeting, so there will be food.

I hope you can make it out.

Adogo presentation went long

Brian LeGros | February 10th, 2009 | news  

Last night I gave my 2nd pass at my “Continous Integration” presentation that I will be giving at FlexCamp Miami in March. The presentation went an hour and forty minutes … yeah, it was really long winded. People were receptive to the content, I just think it was a lot to process in one session. Dan had some great suggestions about shortening the amount of time spent on locking strategies in source control, which should give me a lot of time back. I know the conference was looking for a testing topic and I gave them a CI topic, so I’ll probably also focus more on testing and examples than the rest of the content. After listening to myself on the recording, I also think I need laugh a little less at my own jokes, and be a little more professional; I’ll be working on that in the coming weeks.

If anyone who was at the meeting, or wants to watch the recording, has some time, I’d really be up for feedback on the presentation content and my presentation style. Feel free to let ‘er rip and don’t hold any punches. I can take it :*(

Presenting at the Adogo this month

Brian LeGros | February 3rd, 2009 | news  

It seems like every month, the Adogo and RAnDOM meetings creep up on me. That being said, we’ve pushed the Adogo meeting for February back to February 9th this month instead of yesterday, February 2nd, to try and make up some time to prep. I will be presenting on the topic of “Continuous Integration” (primer) and afterward we’ll be having a round-table discussion about what everyone’s been up to and working on. Should be a pretty lay back meeting and I promise to put everyone to sleep, so bring your pillows. This will be a practice run for my the presentation that I will be giving at FlexCamp Miami on March 6th, so if you like what you see (with, or without. the sexual overtones), you should try to make it down for a day of fun with Flex.

See ya Monday, if you can make it; if not, thanks for sparing me the embarrassment that was inevitable. :’(

RAnDOM is ready

Brian LeGros | August 4th, 2008 | news  

After weeks of planning and months of picking a name, a few of us have finally put together a user group for the Brevard area. The group is called RAnDOM, Rich ApplicatioN Developers Of Melbourne. Our blog is located @ http://itsrandom.info. If you’re interested, you can see the cool layout that Sebastian put together for us.

My hope is that by bringing this group to Brevard we can begin to really grow the developer community in the area. We have an active .NET user group and Florida Creatives is getting started, but as far as coding goes, there aren’t that many opportunities to learn in a hands on way. At the Adogo, I really enjoyed our code camps these past few months, so I think that since we’re likely to start small, we can establish a great group by just hacking away. The area also seems to have a lot of web consulting companies, so maybe we can even a few of them to come out.

I really want a place to get together with fellow developers to code and discuss whatever may come over a cool beer and some wifi. If this is what does it, right on; if not, at least I still got a cold beer.

:)

Anyone interested in an Adobe group in Brevard?

Brian LeGros | July 7th, 2008 | programming  

As the Adogo has grown over the last year, I’ve noticed that a few people, like myself, make the trek from the Space Coast into Orlando for our monthly meeting. In an effort to bring the work of the group to Brevard County, I was wondering if anyone would be interested in participating in an Adobe group locally? Initially I’d be interested in just getting together a local coffee shop or pub and doing hackfests with Flex, ColdFusion, AIR, and whatever else we can get our hands on. As attendance grows, maybe we could get into presentations, but until then, I’d like to keep it layback. I’m still looking to stay involved in the Adogo, but who can turn down getting away and coding for a few hours each month.

I’m looking for spots to have the meeting still, but things close pretty early in the Melbourne area; does anyone have any ideas about good joints that could support us? I’m looking into Charlie and Jake’s in Suntree or possibly the Sun Shoppe Cafe (coffee shop) in downtown Melbourne. I’d love find something beachside, but I’m not sure where to look. If people are interested we also need to come up with a name, date, and time. Any suggestions?

As I put together more information, I’ll post about them here. Please comment and let me know if you would attend. Check back soon for more details.

Made it through the April Adogo

Brian LeGros | April 3rd, 2008 | news  

Well, looks like I made it through the April Adogo meeting with both my presentations on BlazeDS. I put quite a bit of work into the presentations, so thanks to all of those who attended the presentation. We’ve updated the Meetings page with links to the recordings if anyone is interested. I have to apologize for the quality of the sound, however; I think I accidentally messed up the white noise calibration. In any case, thanks to the Adogo for having me as always.

Adogo April Meeting Tomorrow

Brian LeGros | March 31st, 2008 | news  

Well I’ve finally put the finishing touches on my Adogo presentation for tomorrow night on the “Mechanics of BlazeDS” and “Remoting and Messaging with BlazeDS”. I originally called the 2nd presentation “RPC and Messaging with BlazeDS”, but I didn’t have an opportunity to integrate SOAP/REST into the picture, so I’m renaming it. In any case, I was able to throw together a pretty cool little sample app that should allow for some audience participation (pending my laptop can spare the memory). Hopefully some of my former co-workers from CFI can make it out. Sebastian and I will be driving out right after work, so see you all there.

Also, there will be food this time around thanks to TekSystems, so worst case, come out, be fed, and ridicule my meager presentations.

:)