Testing Scene Assistants: Sample Code Soon?

5 views
Skip to first unread message

P. Douglas Reeder

unread,
Aug 24, 2010, 10:08:13 AM8/24/10
to jasmine-webos
Will there be sample code for testing scene assistants any time
soon? I've written 252 unit tests using Mojo.Test, so the main
reason to switch to Jasmine would be testing scene assistants.

Davis Frank

unread,
Aug 24, 2010, 10:33:44 AM8/24/10
to jasmin...@googlegroups.com
Testing Scene Assistants is a bit tough.  The life-cycle is asynchronous and has changed subtly between SDK releases.  In short, it can be maddening.

To get you started, take a look at jasmine.webos.createStubSceneAssistant.

You can treat this constructor just as if you new'd up your own scene assistant - it takes the same arguments as a scene push. It will create a stub scene controller and stage controller, each with their most common APIs hooked up with Jasmine spies. The scene will have DOM, but since the DOM is memory, you will not be able to test events.  

From there you can unit test any new methods you want and verify that you call Mojo apis properly.

Another pattern - and this is why I've not gotten any sample source posted yet - is a bit more complicated. It puts app logic in its own class allowing you a more behavioral testing approach. More on that soon - but it's great because it allow for easier refactoring without too much test impact.

Thanks for your interest!

--dwf
Reply all
Reply to author
Forward
0 new messages