- Headless (no browsers!)
- Test framework agnostic
- Generates pretty HTML coverage reports
- Finds your tests -- no need to specify each test file
- Filter by Regular Expression
- Not dependent on node.js/npm
- Nothing to install except Ruby Gems
gem install jcov
There are both JSpec and Jasmine example projects in the examples directory -- these are a good place to start.
- jcov run: Runs the tests. Also the default command (just type 'jcov')
- jcov check: Check the configuration.
- jcov help: Show help docs.
-c, --config FILE Specify a configuration file to use -h, --help Display help documentation -v, --version Display version information -t, --trace Display backtrace when an error occurs
-t, --test REGEX Limit the tests to only the ones that match the regular expression --verbose Verbose test execution --[no-]color Enable/Disable color output -- default enabled when executed from the command-line --[no-]coverage Enable/Disable coverage output -- default enabled --report Report test coverage
Running with the
--report switch will output an HTML coverage report that shows line-by-line coverage.
If your testing framework supports color output your runner file must pass the color boolean value from the JCov object (
JCov.options.color) to the framework (see the Jasmine and JCov examples).
--verbose switch is another option your framework must support (see the JCov example).
Run will also return with a non-zero code when the tests don't pass so it can be easily integrated into continuous integration suites.
Configure JCov by creating a jcov.yaml file. JCov also has some "intelligent" defaults and you can see the how the jcov.yaml file works with those defaults using the check command to output the combined configuration:
JCov will look for the jcov.yaml file in a
config directory and the current directory.
Example jcov check output:
report_output_directory: Where the HTML coverage reports will be written. (Default jcov)
This is usually a simple script that loads your testing framework, the source and test files, and calls whatever
execute() method your framework needs. After the tests are run it needs to This is intentionally left open to make it easier for JCov to support arbitrary frameworks.
See the examples directory for examples.
JCov provides some methods and a data object to the runner file.
The JCov object
JCov.tests: An Array of tests to execute (the list of everything from your test directory filtered by the
JCov.config: The configuration loaded from jcov.yaml (see above)
JCov.options: Passed in command line options (see above)
print(): Print to the console.
println(): Print to the console with a carriage return.
load(): load and execute the given file.
readFile(): load file and return it as a string.
putc(): Print a single character to the console.
Headless Browser Testing
Copyright (c) YP Intellectual Property, LLC 2012. JCov is licensed under the MIT License.