A super simple testing framework for quickly validating that certain functions within the application are working properly. In app.js, you would:
Ti.include('runner.js');
Which would add a variable unitTest
to the current context. To create a test,
you would:
unitTest.add({
test: function() {
//assert a boolean that should be true on a successful test,
//plus a description of the assertion
unitTest.assert(true,"This should always be true.");
unitTest.done(); //need to call this when test is done - All tests are assumed to be asynch
},
suite: 'mySuite' // this is optional - by default, all tests run
});
As a shorthand, if you don't want to associate your test with a specific suite, you can also do:
unitTest.add(function() {
unitTest.assert(true,"This should always be true.");
unitTest.done();
});
But since you'll probably have a bunch of tests, this is probably a bad idea - put it
in a suite so you can run tests in groups. In app.js, you'll see the call to unitTest.run()
,
which optionally takes a test suite as an argument.
Check assignments to the api
variable in runner.js