Get help with testing, discuss unit testing strategies etc.


Post by zombeerose »

In my test of a util class, I am calling Ext.require to load the class before testing. The results indicated that I am adding assertions after the test has finished. If I add t.wait/endWait to the test, the assertion warning is removed. Is there a better (less verbose) way to require a class?
StartTest(function(t) {
    t.diag("Some class");

    t.wait('require');
    Ext.require('Ext.ux.some.Class',function(){
        t.endWait('require');

        //tests...
    });

Post by mats »

Put its url in 'alsoPreload' on the test config, way easier :)

Post by nickolay »

zombeerose wrote:If I add t.wait/endWait to the test, the assertion warning is removed.
How so? It should work with the code you posted.
zombeerose wrote: Is there a better (less verbose) way to require a class?
How about this in the ExtJS assertions pack?:
t.requireOk("Class1", "Class2", function () {
   ...
})
Will try to load the classes and verify that they have been created.

Post by zombeerose »

@mats - could work but it has 2 drawbacks for me: a) the include path will be rather long, which is why I make use of the Ext.Loader and b) I would like to keep references to my classes isolated to the test file thereby avoiding having to keep the includes defined in the index file in sync with the usage defined in the test file.

@support_team - just to clarify, the code I posted (with wait/endWait) does work. I'm looking for a shorter solution if possible. So with that in mind, "t.requireOk" would be awesome! I don't see that in the API so I am assuming that would be new.

Thanks !

Post by nickolay »

Yup, its going to be a new assertion in ExtJS layer, scheduled for 1.0.4 I think.

Post Reply