Once you clone jasmine-iphone from GitHub (it includes Jasmine as a submodule, so be sure to
git submodule init && git submodule update) you can copy the example-suite.js file, import your spec files, point Instruments at your suite.js and go.
As an example, I set up a trivial example in the Cedar project. The directory structure looks like this:
Project Directory - Spec - UIAutomation - jasmine-iphone <--- submodule - jasmine <--- nested submodule - suite.js - thing-spec.js - other-thing-spec.js
The suite.js file is relatively simple (note that I moved it up one directory from where the example-suite.js file is, so the #import statements are slightly different):
#import "jasmine-iphone/jasmine-uiautomation.js" #import "jasmine-iphone/jasmine-uiautomation-reporter.js" // Import your JS spec files here. #import "thing-spec.js" #import "other-thing-spec.js" jasmine.getEnv().addReporter(new jasmine.UIAutomation.Reporter()); jasmine.getEnv().execute();
You can write the specs themselves the same way you’d write Jasmine specs for anything else. The UIAutomation subclass of the Jasmine Reporter takes care of marking the start of each spec, as well as reporting if it passes or fails. You’ll need to use the UIAutomation classes and methods for driving your application’s state, of course.
That’s it. Try it out and see what you think.
About the Author
BiographyMore Content by Adam Milligan