You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Lorin Beer (JIRA)" <ji...@apache.org> on 2013/10/24 00:16:44 UTC

[jira] [Assigned] (CB-4050) The async automated test are unnecessarily slow

     [ https://issues.apache.org/jira/browse/CB-4050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lorin Beer reassigned CB-4050:
------------------------------

    Assignee: Lorin Beer  (was: Filip Maj)

> 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: Lorin Beer
>            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 was sent by Atlassian JIRA
(v6.1#6144)