Monday 7 December 2009

Async FlexUnit 4 testing

So the JSONCallHelper() of the last post needs better testing.
I gave it the following signature...
public static function JSONCall(urlQuery:String, responder:IResponder):void
...but then went looking for how to test in FlexUnit 4.
addAsync()(as mentioned here) seems to be a FlexUnit 0.9 (as they call it) capability (due to not finding in a search of checked-out SVN workspace of FlexUnit 4).

There are a selection of  Async.* methods listed here.  The obvious one seemed Async.asyncResponder() but using it seems to only hang my test-suite.

Hmm, perhaps I might have misunderstood what AsyncResponder is for.


OK, debugger reveals it's actually my use of ILogger rather than Parsley's Logger class!
I switched to the following (endeavouring to achieve similar behaviour to Parsley's within a project that doesn't link Parsley):
Log.getLogger(flash.utils.getQualifiedClassName(JSONCallHelper));
...and the debugger revealed the following error was being hidden:
Categories can not contain any of the following characters: []`~,!@#$%*^&()]{}+=|';?><./".
For some reason FlexUnit lost the error / silently swallowed it, then hung rather than finishing its timeout on my async! Weird.
Switched to using simple classname string, corrected URL under test and ...

... now getting HTML not JSON despite wireshark showing I did supply the correct Accept header. Tomorrow.

No comments:

Post a Comment