B3 MVC Controller Unit Test Problems

B3 MVC Controller Unit Test Problems

I am having one hell of a time getting a simple Jasmine unit test to run for one of my controllers because of its dependency on Ext.app.Application. I am getting one error after another from the Loader even after overriding the bindReady function in Ext.app.Application. I really think an example of some simple unit tests needs to be included in the final release.

Still very much looking for help with this. MVC in Sencha Touch includes hooks to disable automatic application loading which is required to enable unit testing of controller classes. I do not see the same hooks when browsing the source for MVC in ExtJS 4.

TypeError: Cannot call method 'getModel' of undefined

TypeError: Cannot call method 'getModel' of undefined

I run into the same problem. I like to write some unit tests for my controllers using Jasmine. However I cannot create a controller using Ext.create because of the TypeError: Cannot call method 'getModel' of undefined.

I browsed the svn source code but could not find how to handle this. However, I would very much appreciate to be able to write unit test. By the way, at the moment I am using the latest production code for ExtJs 4.0.

I can only hope that the development team is still looking at this. As far as I can tell the MVC framework is not unit testable in its current form. It is also not possible to developing a controller in isolation without adding it to an Ext.app.Application first.

I posted this in another thread. It illustrates the coupling in the app package.

I just passed the reference of the parent application to the application property of the controller. Now the first test passes. The second test fails, but this was ment to fail, I would like to write the test, then I write the code;-).

Of course I am not quite sure whether this controller created this way actually works but I am going to test it.

Halcwb - I didn't get very far going down that road. You will have more luck if you disable automatic Viewport creation and override your applications launch function in the unit test. Otherwise your Viewport will load. Either way all of your other controllers will still load because there is no hook to prevent this (well that I could find).

I think it is worth mentioning what it is I want to test. Basically I want to be able to regression test my refs and control statements. Any other logic can be moved to an easier to test class and any business logic should be moved to the server. I don't want to render UI components for these unit tests if I can avoid it. Selenium can be used for that kind of integration level test.