/JsChilicat

JsChilicat is a JavaScript framework for headless testing.

Primary LanguageJavaScript

Welcome to JsChilicat

JsChilicat is a JavaScript(ECMA 262) framework for headless testing. JsChilicat will use the Mozilla Rhino Engine to execute JavaScript unit tests without opening a browser. The framework has EnvJs integrated which will simulate the Browser Environment (DOM). As test framework is QUnit integrated which is also used by JQuery.

Prerequisite

You need a installed JDK or JRE 6. It might also work with JDK/JRE 5 but I have developed on JDK 6. You need a JsChilicat distribution which can be found in the download section of the github project. https://github.com/chilicat/JsChilicat

Or you have to build JsChilicat form the sources. To checkout the code please see github details.

Usage

Download the distribution. Open a terminal or a console and go into the libs directory. In the libs directory you will find a jschilicat.jar. By issuing

java -jar jschilicat.jar

you will get a list of all available command parameters.

JsChilicat has Selenium integrated which allows you to run your tests in different browsers. Currently we support Google Chrome and Firefox. We also support two headless browsers, the first is htmlunit from Selemium and the second is the JsChilicat internal. Both uses Rhino javascript engine underneath. The difference between those two browsers is the DOM emulation. The JsChilicat internal browser is currently the only one which supports the code coverage. The junit report is supported by all supported browsers

Start tests in Firefox:
java -jar jschilicat.jar -firefox

Start tests in Google Chrome:
java -jar jschilicat.jar -chrome

Start test in htmlunit:
java -jar jschilicat.jar -htmlunit

Start test in JsChilicat internal:
java -jar jschilicat.jar -chilicat

If you have selected your browser than you must set you working directory. The working director will contain the test result and coverage files. By default is the current directory the working directory

java -jar jschilicat.jar -<browser> -workingDir /dev/results

Now we want to specify the our test sets. JsChilicat will differ between three sources: libraries, sources and tests.

A library in is a third party javascript file for your project. For example jquery is a third party library. A javascript file which will be configured in the as library will not be tracked for code coverage and unit test reports. The sources are your javascript files which should be tested and measured (unit/coverage report) And finally the tests which are, as expected, your unit test files.

The order of loading the liberties is always:
libraries -> sources -> tests

Lets issue a hypothetical test run:

java -jar jschilicat.jar -<browser> -workingDir /Users/jschilicat/dev/results \ -libs /dev/libs -src /dev/src -src-test /dev/test/
As you can see I specified directories. For convenience reasons is it possible to do that. What happening is that JsChilicat will search recursive for *.js files and includes them. That's of course for many projects not a solution to go because most javascript libraries expect to be loaded in a certain order. That can be achieved by file lists. For example:

-libs /dev/jquery.js;/dev/otherLib.js
-src ...
-src-test ...

Note: The separator is platform depended. Windows uses semi-colon (;) and mac uses colon (:)

We support also simple text files which just contains a list of all javascript files. The text file must have the extension .jsl

/dev/example.jsl

Content:

---
/dev/test5.js
/dev/test1.js
/dev/test2.js
/dev/test1.js
/dev/test4.js
---

The file in a .jsl must be relative to the parent of the .jsl file.

Just specify the .jsl file like a normal javascript file:

-test-src /dev/example.jsl

License

The MIT License (MIT)

Copyright (c) 2013 chilicat

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.