Twitter Call us on +44 (0)1256 486557

Instantiating controllers for unit testing in Sencha Touch 2.2

When unit testing controllers you may want to create a new instance of the controller for each test. ¬†It’s not possible to instantiate controllers directly in Sencha Touch simply using Ext.create.

You need to pass a reference to a Sencha Touch application but due to the nature of unit testing you may not have access to one.  Therefore the simplest way to do this is to create a dummy app and use this for your controller to bind to.

See the demo code below: