<TestSuite>
A view that comprises a suite of LZUnit tests.

JavaScript: lz.TestSuite
extends <Test> » <DebugObject> » <view> » <node> » lz.Eventable »

This is the LZUnit library. LZUnit is an implementation of the xUnit testing framework for LZX programs (cf., JUnit A Cook's Tour).

Each of the xUnit components is implemented as an LZX tag with the corresponding name. Tests can be written by defining a subclass of TestCase and defining test methods. A test suite can be created by enclosing any number of TestCases in a TestSuite.

The usual helper methods, assertTrue, assertEquals, assertWithin, assertSame, etc. are available for implementing the tests. (See the documentation of Test for a full list.)

An LZX program that consists of a TestSuite will, when loaded, automatically run all of its child TestCases and report the number of test cases run, the number of failures, and the number of errors. If any error occurs, an obvious error message is presented.

Below is a simple example of the use of LZUnit demonstrating a successful test, a failed test, and a test that causes an error.

[Note] Note

You must run LZUnit with debugging on for it to detect errors.

For a more in depth discussion, please see the Developer's Guide.

<canvas debug="true">
                      <debug y="275"/>
                      <include href="lzunit"/>

                      <class name="Tautologies" extends="TestCase">
                        <method name="addTests" override="true">
                          addTest("testSuccess");
                        </method>

                        <method name="testSuccess">
                          assertTrue(true);
                          assertFalse(false);
                          assertEquals(null, undefined);
                          assertWithin(0, .001, .01);
                          assertSame(null, null);
                          assertNotSame(null, undefined);
                          assertNull(null);
                          assertNotNull(undefined);
                          assertUndefined(undefined);
                          assertNotUndefined(null);
                        </method>
                      </class>

                      <class name="IntentionalBugs" extends="TestCase">
                        <method name="addTests" override="true">
                          addTest("testFailure");
                          addTest("testError");
                        </method>

                        <method name="testFailure">
                          fail("This is an intentional failure");
                        </method>

                        <method name="testError">
                          error("This is an intentional error");
                        </method>
                      </class>

                      <TestSuite>
                        <Tautologies/>
                        <IntentionalBugs/>
                      </TestSuite>
                    </canvas>

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
controlPanel expression any canvas.lzunitControlPanel read/write
   

Attributes inherited from <DebugObject>

debugWrite

Methods

addTest()
TestSuite.addTest(theTest);
Manually add a TestCase to the TestSuite.
Parameter Name Type Description
theTest   the test to add

Methods inherited from <formatter>

abbreviate, formatToString, pad

Methods inherited from <DebugObject>

jsTrue, xmlequals, xmlstringequals

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onsuitefinish  
onsuitestart  
ontestfail  
ontestfinish  
onteststart  

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy