From a0e1bec9d72db9258a6372feee1be922b3dab443 Mon Sep 17 00:00:00 2001 From: Solly Date: Wed, 4 Dec 2013 12:41:14 -0800 Subject: [PATCH] Introduced testing instructions --- Testing.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Testing.md diff --git a/Testing.md b/Testing.md new file mode 100644 index 0000000..eb42723 --- /dev/null +++ b/Testing.md @@ -0,0 +1,54 @@ +Running Tests +============= + +There are two types of tests in noVNC: manual test pages and automated Mocha tests. + +Manual Tests +------------ + +The manual test pages take the form of HTML files (although some of the HTML files are used for running +Mocha tests -- see below). They can be run by simply opening them up in a web browser and interacting with them. + +Mocha Tests +----------- + +The Mocha tests take the form of Javascript files named `test.*.js`. They can be run two ways. The first is to run them using the `run_from_console.js` script in the `tests` directory. More information about this can be found below. The second way to run the Mocha tests is through a web browser. Some of the tests have also have pre-written HTML files that load and run them. You can open these files in your browser of choice to run the tests. For tests which do not have such files, you can use the `-g` and/or `-o` options to generate web pages to view (the former creates a temporary file which lasts until the program is terminated, while the latter just outputs the HTML source to STDOUT). + +### Using `run_from_console.js` ### + +The tool `run_from_console.js` is capable of running both collections of Mocha tests in HTML files, as well as Mocha tests in their direct Javascript form. For the former, run the following command: + + $ tests/run_from_console.js -t tests/some_file.html + +For the latter, you must also specify the Javascript files upon which the tests depend: + + $ tests/run_from_console.js -t tests/test.something.js -i include/somefile.js + +The `run_from_console.js` tool also has additional options. Run it with `--help` for more information. + +### Requirements ### + +The following NPM packages are needed to run the Mocha tests: + +- chai (*must* be installed locally, used in tests) +- mocha (*must* be installed locally, used in tests) +- ansi (used in `run_from_console.js`) +- commander (used in `run_from_console.js`) +- temp (used in `run_from_console.js`) + +Additionally, you will have to choose an environment for the `run_from_console.js` tool. The default environment is CasperJS, which uses an isolated WebKit-based environment to realistically simulate a browser environment. To use CapserJS, you will need the following packages: + +- casperjs (*must* be installed locally) +- phantomjs +- phantom +- spooky + +The other environment is ZombieJS. ZombieJS is written purely in Javascript, and creates a fake DOM, so it is more lightweight, but less realistic. To use ZombieJS, you need to pass the `-p zombie` option to the `run_from_console.js` tool, and need the following packages: + +- zombie +- q + +Writing Tests +============= + +New tests should be written using the [Mocha](http://visionmedia.github.io/mocha/) test platform and the [Chai](http://chaijs.com/) assertion library. You do not need to do anything special to use these libraries in your tests; they are automatically injected by the `run_from_console.js` tool into the autogenerated web pages. The tests should be placed in the `tests` directory, and should follow the naming convention of `test.whatever_it_is_you_are_testing.js`. There are several example tests to get you started. If you wish to see the actual Mocha test pages in a web browser, you can use the `-g` and/or `-o` options described above. \ No newline at end of file