JSUnit Test Runner Application
| JSUnit Test Runner |
| Type | XAR |
| Category | |
| Developed by | |
| Rating | |
| License | GNU Lesser General Public License 3 |
Table of contents
Description
Integration of JSUnit "Unit Testing framework for client-side (in-browser) JavaScript" into XWiki. It lets you run its javascript test runner from XWiki, and write your tests directly in XWiki pages.
Please, report to the Github page for more information or documentation about JSUnit.
Usage
Run JSUnit standard test runner
Once you have the application installed, just point your browser to http://yourserver/xwiki/bin/view/XWiki/JSUnit and you will be offered JSUnit's standard test runner.
Write javascript tests as XWiki pages
With the XWiki integration of JSUnit, you can write test cases or test suites directly as wiki pages. For this, you just need to JSX use the page XWiki.JSUnit, and you can get started:
$xwiki.jsx.use("XWiki.JSUnit")
<script type="text/javascript">
function testSomething(){
assertEquals(1, 1);
}
...
</script>As a bonus, you can add a test runner for your XWiki test page, which will offer you in view mode a button to run only the test case/suite that is hosted on the wiki document.
For this, just include XWiki.JSUnit with the velocity includeTopic macro, like in this following code:
#includeTopic("XWiki.JSUnit")
$xwiki.jsx.use("XWiki.JSUnit")
<script type="text/javascript">
... // your tests here
</script>Then you'll be able to run the tests/suite defined directly on its own page:

Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:
- Log in the wiki with a user having Administration rights
- Go to the Administration page and select the Import category
- Follow the on-screen instructions to upload the downloaded XAR
- Click on the uploaded XAR and follow the instructions
- You'll also need to install all dependent Extensions that are not already installed in your wiki