Silicon Forks Home
Blog
JSCoverage
NRuler
Documentation
Forum

Silicon Forks

Using JSCoverage with the MooTools test suite

This is the fourth in a series of articles about using the JSCoverage tool with various JavaScript testing frameworks:

  1. Using JSCoverage with the script.aculo.us test suite
  2. Using JSCoverage with the MochiKit test suite
  3. Using JSCoverage with the jQuery test suite
  4. Using JSCoverage with the MooTools test suite (this article)

First, we need to check out MooTools from its Git repository. We will check this out into the F:\ directory. The repository contains a .gitmodules file referencing Git submodules; we will need those too:

git clone http://github.com/mootools/mootools-core.git
cd mootools-core
git submodule init
git submodule update

MooTools actually has two test suites: one in the Specs directory and one in the Tests directory. The one in Tests is newer and does not have very many tests in it yet, so we will skip that one and just run the one in the Specs directory. To run the test suite, we open the URL file:///F:/mootools-core/Specs/index.html in a web browser:

The MooTools test suite

It lists a number of test suites; we will choose to run “MooTools-Core 1.3: 1.2public + 1.3public”. Clicking on the link loads the URL file:///F:/mootools-core/Specs/runner1.3.html?specs=1.2public&specs=1.3public:

The MooTools test suite

We will instrument this code using the jscoverage tool. We will use the --exclude option to skip the Tests directory and the --no-instrument option to avoid instrumenting the test suite in the Specs directory:

jscoverage --exclude=Tests --no-instrument=Specs mootools-core instrumented-mootools

To run the instrumented tests, usually we open in our web browser a URL of the form file:///.../jscoverage.html?URL, where URL is the URL of the test suite. But note that the test suite URL contains some special characters, so we need to encode these when putting them in a URL:

file:///F:/instrumented-mootools/jscoverage.html?Specs%2Frunner1.3.html%3Fspecs%3D1.2public%26specs%3D1.3public

We can open this in our web browser:

The MooTools test suite, instrumented using JSCoverage

The “Summary” tab displays coverage statistics:

The JSCoverage "Summary" tab

Tomorrow we will look at using JSCoverage with the YUI test suite.

Comments are closed.