LzTest API
From OpenLaszlo
LzTestManager.lzx is generic lzx; it works in the browser (swf7 or greater, and dhtml) and in rhino, as a command-line-only tool. Test cases and test suites are constructed in script blocks within lzx code. An example test suite is in test/lztest/lztest-simple.lzx. When test suites are created following the pattern in lztest-simple.lzx, tests are automatically run and reported on.
There are three steps to making a new test case. First, create an instance of LzTestSuite. Instances of LzTestSuite are discovered by the test harness.
var suiteSimpleToo = new LzTestSuite("Simple2 Test Suite");
Next, write test functions which call LzTestManager.assertTrue and other LzTestManager.assert methods. LzTestManager provides the usual assertion methods: assertTrue, assertEquals, assertWithin, assertSame, assertNotSame, assertNull, assertNotNull, assertUndefined, assertNotUndefined.
suiteSimpleToo.minimalTest = function () {
LzTestManager.assertTrue( true, "minimal test");
}
Finally, add test functions to the test case:
suiteSimpleToo.addTest(suiteSimpleToo.minimalTest);
The list of tests in test/lztest/smokecheck.txt only includes test which currently pass the rhino runtime, so that the build will succeed. The existing tests which fail are listed in test/lztest/smokecheck.lzx, preceded by a # so they are not executed.
"ant lztest" invokes rhino and runs the new smoketest in the rhino
runtime. The new smoketest is currently just a port of test/smoke/simple.lzx
to the new LzTestManager api. It does not cover the intentional failures,
intentional errors, or testing the debugger itself.
From a command line, run ant runlztest to run the tests in rhino. To run the tests in dhtml and swf, use these urls, and urls like them, as more tests are added.
- http://localhost:8080/lps-legals/test/lztest/lztest-output.lzx?debug=true&lzr=dhtml
- http://localhost:8080/lps-legals/test/lztest/lztest-output.lzx?debug=true
- http://localhost:8080/lps-legals/test/lztest/lztest-events.lzx?debug=true&lzr=dhtml
- http://localhost:8080/lps-legals/test/lztest/lztest-events.lzx?debug=true
- http://localhost:8080/lps-legals/test/lztest/lztest-ids.lzx?debug=true&lzr=dhtml
- http://localhost:8080/lps-legals/test/lztest/lztest-ids.lzx?debug=true
- http://localhost:8080/lps-legals/test/lztest/lztest-simple.lzx?debug=true&lzr=dhtml
- http://localhost:8080/lps-legals/test/lztest/lztest-simple.lzx?debug=true
- http://localhost:8080/lps-legals/test/lztest/lztest-selftest.lzx?debug=true&lzr=dhtml
- (fails) http://localhost:8080/lps-legals/test/lztest/lztest-selftest.lzx?debug=true
- (fails silently) http://localhost:8080/lps-legals/test/lztest/lztest-lzbrowser.lzx?debug=true&lzr=dhtml
- http://localhost:8080/lps-legals/test/lztest/lztest-lzbrowser.lzx?debug=true

