[ 
https://issues.apache.org/jira/browse/CB-4050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13695765#comment-13695765
 ] 

Andrew Grieve commented on CB-4050:
-----------------------------------

Agree this is annoying. I've already updated most of the FileTransfer tests to 
do this. They use the helper function "waitsForAny" in autotest/test-runner.js.


                
> The async automated test are unnecessarily slow
> -----------------------------------------------
>
>                 Key: CB-4050
>                 URL: https://issues.apache.org/jira/browse/CB-4050
>             Project: Apache Cordova
>          Issue Type: Wish
>          Components: mobile-spec
>            Reporter: Xavier Vergés
>            Assignee: Filip Maj
>            Priority: Minor
>
> The automated tests in {{cordova-mobile-spec/autotest}} are coded to wait 
> only for the expected callback and do not wait for the callback that will 
> only be called when the test fails. This causes some of the failing tests to 
> have to wait for a timeout.
> {code:JavaScript|title=test that expects fail callback to be called}
> // create jasmine spies as a success and failure callback
> var win = ...;
> var fail = ...;
> // make call, passing the two spies
> runs(function() {xxx(win, fail); });
> // wait for fail to be called 
> waitsFor(function() { return fail.wasCalled; }, 
>   "error callback never called", 
>   Tests.TEST_TIMEOUT);
> // verify the spies state
> runs(function() {
>                     expect(win).not.toHaveBeenCalled();
>                     expect(fail).toHaveBeenCalled();
>                 });
> {code}
> If the implementation is broken and calls the {{win}} callback, the test 
> won't finish until TEST_TIMEOUT expires. The above pattern is pervasive in 
> the tests in {{cordova-mobile-spec/autotest}}
> If the code would check that any of the callbacks have been called
> {code:JavaScript}
> // wait for either of the two callbacks to be called 
> waitsFor(function() { return fail.wasCalled | win.wasCalled; }, 
>   "callback never called", 
>   Tests.TEST_TIMEOUT);
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to