Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bodil/testlol
A Maven test runner for Javascript using Rhino and Env.js
https://github.com/bodil/testlol
Last synced: 2 months ago
JSON representation
A Maven test runner for Javascript using Rhino and Env.js
- Host: GitHub
- URL: https://github.com/bodil/testlol
- Owner: bodil
- Created: 2009-08-12T16:34:59.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2011-07-26T19:17:47.000Z (over 13 years ago)
- Last Synced: 2024-04-15T12:19:16.825Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 871 KB
- Stars: 13
- Watchers: 4
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
ABOUT
=====Testlol is a Maven plugin for running Javascript unit tests in a headless browser
environment. It is built on Rhino, Env.js and JsUnit.HOWTO
=====To use in your own project, add this to your POM file, and edit as appropriate:
tv.bodil
maven-testlol-plugin
1.0
test
test
src/main/resources/js
src/test/js/tests
src/test/js/jquery.js
Your tests might look like this:
load(basePath + "classToTest.js");
function testMyClass() {
var obj = new MyClass();
assertEquals(4, obj.add(2, 2));
}The "basePath" variable in the first line is simply the path configured in the
"basePath" property in the POM, and should point to the base of the code tree
you are testing.Point the "testSuite" property at your test files. It will scan this directory
recursively and run through any file found inside it ending with the ".js" prefix.
Any function whose name starts with the word "test" is considered a test. If there
is a function called "setUp" in the file, it will be run prior to executing the
tests. Likewise, a function called "tearDown", if present, will be run after the
tests have finished executing.You can preload Javascript files into your test environment using the "globalFiles"
property. Use this to load eg. frameworks and toolkits. Never load code you are
testing in this way, because it is shared between every test suite, and changes
made in one test will persist into the following tests.To learn about writing tests, refer to the JsUnit documentation. All JsUnit
asserts etc. are available in the Testlol environment.