Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I see nothing wrong with using the async version. I can agree that the second version is shorter, but I'm not sure that I think it's easier to follow. The test does a lot of things that you wouldn't normally do, whereas the first example is more true to how you would use the component outside the test environment.</p> <p>Also, in the second form you have to make sure that you do exactly what the framework would do, miss one step and your test isn't relevant, and each test must repeat this code. Seems to me it's better to test it in a situation that is as close to the real thing as possible.</p> <p>You could have a look at <a href="http://code.google.com/p/dpuint/" rel="nofollow noreferrer">dpUint</a>'s <a href="http://code.google.com/p/dpuint/wiki/Sequences" rel="nofollow noreferrer">sequences</a>, they made component testing a little more declarative:</p> <pre><code>public function testLogin():void { var passThroughData:Object = new Object(); passThroughData.username = "myuser1"; passThroughData.password = "somepsswd"; var sequence:SequenceRunner = new SequenceRunner(this); sequence.addStep(new SequenceSetter(form.usernameTI, {text:passThroughData.username})); sequence.addStep(new SequenceWaiter(form.usernameTI, FlexEvent.VALUE_COMMIT, 100)); sequence.addStep(new SequenceSetter(form.passwordTI, {text:passThroughData.password})); sequence.addStep(new SequenceWaiter(form.passwordTI, FlexEvent.VALUE_COMMIT, 100)); sequence.addStep(new SequenceEventDispatcher(form.loginBtn, new MouseEvent("click", true, false))); sequence.addStep(new SequenceWaiter(form, "loginRequested", 100)); sequence.addAssertHandler(handleLoginEvent, passThroughData); sequence.run(); } </code></pre> <p>(example from the <a href="http://code.google.com/p/dpuint/" rel="nofollow noreferrer">dpUint</a> wiki, <a href="http://code.google.com/p/dpuint/wiki/Sequences" rel="nofollow noreferrer">see here for more info</a>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload