Projects‎ > ‎XBL‎ > ‎

XBL Components Unit Testing

Principles

  • We want XBL components to be thoroughly unit tested, hence unit tests should be easy to write.
  • Unit tests for XBL component must fit into our existing unit testing client-side framework (which can be changed if necessary).
  • Unit tests be must part of the XBL component; the unit test is part of the component: its files must be in the same location as the other files implementing the component.

Cookbook – Creating a New Test

Assuming your component is named my-widget, in the package acme, then the XBL file for the component is stored in xbl/acme/my-widget/my-widget.xbl.
  1. In the same directory as my-widget.xbl, create a file my-widget-unittest.xhtml.
    • This is a simple XHTML file, just like those you run in the sandbox.
    • If you need more than one file, be more descriptive (e.g. my-widget-unittest-particular-situation.xhtml).
  2. Write the XHTML like you would write any other test running in the XForms sandbox.
  3. Run your test in the browser by loading http://localhost:8080/orbeon/xforms-sandbox/sample/xbl/acme/my-widget/my-widget-unittest.
  4. Include the test in the test suite editing apps/xforms-sandbox/samples/unit-tests.xhtml.

Possible Improvements

  1. Step 4 above, breaks componentization. Maybe the unit test driver can automatically discover the tests to run by lookup up the units test based on their name.
Comments