Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

JSUnit: Difference between revisions

From MoodleDocs
(Created page with "{{Work in progress}} Admin tool to wrap Javascript unit tests execution. Is based on YUI test module, taking profit of the dependencies system to avoid core modifications. Test...")
 
No edit summary
Line 3: Line 3:
Admin tool to wrap Javascript unit tests execution. Is based on YUI test module, taking profit of the dependencies system to avoid core modifications.
Admin tool to wrap Javascript unit tests execution. Is based on YUI test module, taking profit of the dependencies system to avoid core modifications.


Test cases can be created like any other YUI 3 module adding a module in the yui/ folder (More info in https://docs.moodle.org/dev/How_to_create_a_YUI_3_module) Tests should include it's dependencies like any other YUI module
Test cases can be created like any other YUI 3 module adding a module in the yui/ folder (More info in https://docs.moodle.org/dev/How_to_create_a_YUI_3_module) Tests should include it's dependencies like any other YUI module.


=Usage=
==Usage==
The link to the unit test execution is in the Administration tree -> Development -> JSUnit
* To execute the tests from the Moodle user interface
** The link is in the Administration tree -> Development -> JSUnit
* To execute the tests from a CLI environment (Not tested)
** A server-face Javascript tool like Yeti is needed (the PHP CLI tool not parses Javascript)
** Install Node.js + Yeti
** Execute admin/tool/jsunit/jsunit_cli.php


=Links=
==Creating tests==
The block_community comments module example can be followed, it's a simple unit test to show how to write them.
 
==Links==
* Tracker issue: [http://tracker.moodle.org/browse/MDL-30899 MDL-30899]
* Tracker issue: [http://tracker.moodle.org/browse/MDL-30899 MDL-30899]
* Development branch: https://github.com/dmonllao/moodle/commits/MDL-35595_master
* Development branch: https://github.com/dmonllao/moodle/commits/MDL-35595_master
* YUI test: http://yuilibrary.com/yuitest/
* YUI test: http://yuilibrary.com/yuitest/
* Yeti: http://yuilibrary.com/projects/yeti/ and https://github.com/yui/yeti/blob/master/README.md
* Yeti: http://yuilibrary.com/projects/yeti/ and https://github.com/yui/yeti/blob/master/README.md

Revision as of 08:56, 24 September 2012

Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.


Admin tool to wrap Javascript unit tests execution. Is based on YUI test module, taking profit of the dependencies system to avoid core modifications.

Test cases can be created like any other YUI 3 module adding a module in the yui/ folder (More info in https://docs.moodle.org/dev/How_to_create_a_YUI_3_module) Tests should include it's dependencies like any other YUI module.

Usage

  • To execute the tests from the Moodle user interface
    • The link is in the Administration tree -> Development -> JSUnit
  • To execute the tests from a CLI environment (Not tested)
    • A server-face Javascript tool like Yeti is needed (the PHP CLI tool not parses Javascript)
    • Install Node.js + Yeti
    • Execute admin/tool/jsunit/jsunit_cli.php

Creating tests

The block_community comments module example can be followed, it's a simple unit test to show how to write them.

Links