Quantcast
Channel: Adobe Community : Popular Discussions - FlexUnit
Viewing all articles
Browse latest Browse all 25673

Better Async testing?

$
0
0

I've been doing a lot of async service testing lately and I'm trying to figure out the "correct" way of doing things.

 

Imagine I have a simple backend with just two methods: createTeam() and getAllTeams().  For example, I usually test the createTeam() method like this:

 

[Test(async)]
public function createTeam():void {
    var token:AsyncToken = service.createTeam('Los Angeles Lakers');
    token.addResponder(Async.asyncResponder(this, new TestResponder(createTeam2, fault), TIMEOUT));
}
public function createTeam2(data:Object, passThroughData:Object = null):void {
    var token:AsyncToken = service.getAllTeams();
    token.addResponder(Async.asyncResponder(this, new TestResponder(createTeam3, fault), TIMEOUT));
}
public function createTeam3(data:Object, passThroughData:Object = null):void {
    var teams:ArrayCollection = data.result as ArrayCollection;
    assertThat('Team not created', 'Los Angeles Lakers', inArray(teams.toArray()));
}

 

This pattern appears to be very common, where multiple methods are chained together via Async.asyncResponder.  I know it works, but does anyone have an opinion, or examples, of a better way to test async services?

 

-Justin


Viewing all articles
Browse latest Browse all 25673

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>