[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 Unit tests, written with [QUnit](http://docs.jquery.com/QUnit), are used to 2 expose bugs for squashing, prevent bugs from respawning, and suppress new 3 bugs when adding new features and making changes. 4 5 # Running the tests 6 7 The simplest way to run the tests is to open `tests/tests.html` in your browser. 8 The test suites will automatically run themselves and present their results. 9 10 To run the tests from the command line, download and install 11 [PhantomJS](http://phantomjs.org/), and run `run-qunit.js` with it: 12 13 $ cd tests/ 14 $ phantomjs run-qunit.js tests.html 15 16 Failed tests and their failed assertions will be printed to the console. A 17 results summary will be printed at the end. 18 19 To generate coverage statistics, use [JSCoverage](http://siliconforks.com/jscoverage/) 20 to instrument the js files: 21 22 $ cd tests/ 23 $ jscoverage ../js/ ../instrumented/ 24 $ phantomjs run-qunit.js tests.html 25 26 Coverage percentage will be included in the output summary, and a highlighted 27 line-by-line html file will be generated. 28 29 # Shout-out 30 31 Thanks to Rod @ While One Fork for the 32 [CIS guide](http://whileonefork.blogspot.com/2011/10/integrating-javascript-tests-into-cli.html) 33 on putting the above together. 34 35 # Adding tests 36 37 Tests go in js files in the `tests/suites/` directory tree. QUnit organizes 38 tests into suites called "modules"; there is one module per js file. If the 39 tests you are adding do not fit into an existing module, create a new one at 40 `tests/suites/<new module>.js`, where `<new module>` is a broad yet 41 descriptive name for the suite. If tests have many year-specific cases (ie, 42 behave differently in leap years vs normal years, or have specific buggy 43 behavior in a certain year), create the module in a new directory, 44 `tests/suites/<new module>/<year>.js`, where `<new module>` is the decriptive 45 name and `<year>` is the four-digit year the tests pertain to. 46 47 In order for new tests to be run, they must be imported into `tests/tests.html`. 48 Find the script includes headed by the html comment `<!-- Test suites -->`, and 49 add a new one to the list which includes the new js files.
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |