Skip to content
mark.birbeck@webBackplane.com edited this page Nov 23, 2010 · 10 revisions
  1. summary Guidance for developers on testing their code.
  2. labels Phase-QA,Component-Docs,Featured

Table of Contents

Introduction

There are three types of testing that are used in backplanejs. The first is unit-testing, which is used to verify that each component within the system works as expected. Since we use _test-driven development_ (TDD) then unit-tests will be the predominant form of test.

The second type of test is integration testing, where we check that one or more components work together.

And finally we have end-to-end testing, which tests that the entire framework hangs together in the correct manner. There will generally only be a few of these types of test.

Unit-testing

The main environment for unit-testing is currently YUITest.

To create unit-tests simply add a file that begins with the prefix `ut-` and place it one of the code directories. Generally we place the files alongside the code being tested, but there are some older tests that reside in their own directory.

To illustrate, in the directory third-party/uxf/src/lib/functions/backplane we have the file serialize.js which contains an XPath function to serialise an XML structure as text. In the same directory is ut-serialize.js which contains the associated unit-tests.

The general pattern of a unit-test file is for the test to register itself with the YUITest framework. All tests are combined into a single roll-up file using the following command from the backplanejs tools (see UsingTools):

To copy the rolled-up test file to a location where the test server can see it, and to also launch the test server, use the following command:

Any sub-directory in the directory defined by `${unit-tests.dir}` is now available to the server. (This is usually `target/tests/unit-tests`.) To illustrate, if the test server had been launched on port `192.168.1.10`, then the tests would be available via the browser at the following locations:

This default configuration is sufficient for most scenarios, but if more directories need to be referred to from the test server then the `yaml` file will need to be updated. This can be found in the `build\test` directory, and the file is called `unit-test-app.yaml`. This file is copied to the GAE area, and in the process tokens are substituted for the directories, and the file is renamed to `app.yaml`.

All of the unit-tests can also be run in one go, in an automated way, via the command:

Ant will exit if any collection of test fails.

Integration tests

The main environment for integration testing is currently Selenium.

End-to-end tests

The main environment for end-to-end testing is currently Selenium.