One of the general idea of the project is to provide a test environment which the developers could start use right away and follow all their old habits. So we provide a simple API which offers underscored and camelised functions which works the same way and in general have well known by another unit-testing systems semantics.
Another main idea of the project is to provide a gui which will not break your existing page layout, design, styles etc. So you could run the test right in your pages environment if you like so. For this reason we have got this popup test-report system. Therefore you can safely include your unit-tests right into your page scripts run them in the loading time.
In additional, since the version 1.0, the reporting system provides some features which allows you to skip/activate the cases right on the report popup, and special select-box which allows you to filter your cases and display/run only the ones you need.
NOTE: if you see those goods disabled, that means you have cookies disabled on your browser. We use cookies to keep the changes active between the page reloads. So you should enable cookies if wish to use the features.
At the moment the library peresents two public classes TestCase and TestSuite. The first one is
the testing base by itself and the second one is a collector for your tests.
To create new unit-test class, you can use two ways.
var MyTest = TestCase.create();
Object.extend(MyTest.prototype, {
testFoo: function() {
this.assertTrue(true);
},
testBla: function() {
this.assertFalse(false);
}
});
var MyTest = TestCase.create({
name: "MyTest", // <- this is an optional test identifier, to see it in the test-results
testFoo: function() {
this.assertTrue(true);
},
testBla: function() {
this.assertFalse(false);
}
});
Once you've got a test-class, you can run it in several ways. First, each test has the method
run(), which can be called as a static method or as an instance method.
// like that
MyTest.run();
// or like that
var test = new MyTest;
test.run();
Another way use the TestSuite class. It is simple as well. Just create a test suite
and put your classes into it. Once you have ran the suite all its tests will get ran automatically.
var test_suite = new TestSuite(Test1, Test2, Test3...);
// or
var test_suite = new TestSuite();
test_suite.add(Test1);
test_suite.add(Test2, Test3, ...);
// you can remove tests out of the list
test_suite.remove(Test2);
// to run all the suite test, use the run() method
test_suite.run();