commit | 5b61fcb58ff182a6e4366a3809d7ab90042af68c | [log] [tgz] |
---|---|---|
author | Michal Mocny <mmocny@gmail.com> | Thu Jul 10 11:32:49 2014 -0400 |
committer | Michal Mocny <mmocny@gmail.com> | Thu Jul 10 11:32:49 2014 -0400 |
tree | 5c11b9918cc82b04459211ee984ab1fdcb2bac20 | |
parent | 500da73f2e7677868165bac07527c1ac84801c7c [diff] |
Moving plugin to root of repo
The org.apache.cordova.test-harness
plugin does two things:
Tests run directly inside existing cordova projects, so you can rapidly switch between testing and development. You can also be sure that your test suite is testing the exact versions of plugins and platforms that your app is using.
Use your existing cordova app, or create a new one.
To make this interesting, add some plugins which actually bundle tests. Here are a few examples:
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git#cdvtest cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git#cdvtest cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git#cdvtest
To run plugin tests, install this plugin.
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-labs.git#cdvtest:cordova-plugin-test-framework
Change the start page in config.xml
with <content src="cdvtests/index.html" />
.
Thats it! Now just cordova run
and explore.
Switch back to application development in-place by removing that line from config.xml
.
Add a <js-module>
named tests
to your plugin.xml
. E.g. org.apache.cordova.device
plugin has this in its plugin.xml
:
<js-module src="test/tests.js" name="tests"> </js-module>
The org.apache.cordova.test-harness
plugin will automatically find all tests
modules across all plugins.
Simply export a function named defineAutoTests
, which (gasp!) defines your auto-tests when run. Use the jasmine-2.0
format. E.g.:
exports.defineAutoTests = function() { define('awesome tests', function() { it('do something sync', function() { expect(1).toBe(1); ... }); it('do something async', function(done) { setTimeout(function() { expect(1).toBe(1); ... done(); }, 100); }); }); define('more awesome tests', function() { ... }); };
Note: Your tests will automatically be labeled with your plugin id, so do not prefix your test descriptions.
Simply export a function named defineManualTests
, which (gasp!) defines your manual-tests when run. Manual tests do not use jasmine-2.0, and success/failure results are not officially reported in any standard way. Instead, create buttons to run arbitraty javascript when clicked, and display output to user using console
or by manipulating a provided DOM element. E.g.:
exports.defineManualTests = function(contentEl, createActionButton) { createActionButton('Simple Test', function() { console.log(JSON.stringify(foo, null, '\t')); }); createActionButton('Complex Test', function() { contentEl.innerHTML = ...; }); };
Note: Your tests will automatically be labeled with your plugin id, so do not prefix your test descriptions.
See: org.apache.cordova.device
's tests.
Use your existing cordova app, or create a new one.
Add this plugin:
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-labs.git#cdvtest:cordova-plugin-test-framework
Change the start page in config.xml
with <content src="cdvtests/index.html" />
.
Thats it! Now just cordova run
and explore.
Switch back to application development in-place by removing that line from config.xml
.
Q: Should I add org.apache.cordova.test-harness
as a <dependancy>
of my plugin?
Q: What do I do if my plugin tests must have very large assets?
Q: Should I ship my app with the test harness plugin installed?
cdvtests/index.html
) from a help section of your app, to give end users a way to run your test suite out in the feild. That may help diagnose causes of issues within your app. Maybe.