PDA

View Full Version : Sencha Touch and TDD



mat1
21 Aug 2011, 4:30 AM
Hi,

i'm trying to build an app with sencha touch by following the principles of test driven development. i'm wondering if there is a best practice to do so. I tried to use jsunit but i got problems with testing controllers of my mvc app.
Anyone tried this so far? I didn't find much in previous posts.

Thanks in advance.
Mat

heringsfilet
21 Aug 2011, 10:34 PM
I would like to know a best practice, too.
Today I'm using jasmine for testing some util JS-files but I haven't tried to test a whole sencha touch app. But this should also be possible...

mat1
22 Aug 2011, 11:47 PM
hi,
thank you for your response, heringsfilet!
Testing util js files is no problem but I can't figure out how to test my sencha touch mvc app components. For example the controllers or stores which are created within the application and seem to work only there...

heringsfilet
22 Aug 2011, 11:52 PM
In jasmine you need to add all files to test (of course). So you need to add your whole application and then write a test for the part you want to test.
This should work if you only use local data. But then you need to ensure that the localStorage is empty before testing the app. If you use remote data, it's hard to write unit-tests as it could be that the connection couldn't be established or something like that.

But I am not used to testing javascript applications, so I don't know if this would work.

fx-mike
23 Aug 2011, 6:08 AM
jasmine allows you to return mock responses for ajax calls, so there is no need to make the actual call.
I don't have an example ready, but the docs are sure to have a nice one