Verifier Hello World

The purpose of a unit test is to test a single class in isolation. Below is an example of a unit of code and an example of a test you would write to verify that the code is correct.

To understand where to put your tests relative to your code, and about how to execute tests, first read Test Infrastructure and Execution.


The example below returns a message if a value is not provided. Otherwise it returns the original value.

novox.ValueUnavailableFormatter = function() {
  this.sMessage = "Value not supplied";

novox.ValueUnavailableFormatter.prototype.format = function(vValue) {
  if(vValue === null || vValue === undefined) {
    return this.sMessage;
  else {
    return vValue;


You declare a new test by instantiating a TestCase, passing it the unique name of your test. You use prototype declarations to create test methods.

ValueUnavailableFormatterTest = TestCase("ValueUnavailableFormatterTest");

ValueUnavailableFormatterTest.prototype.setUp = function() {
  this.m_oFormatter = new novox.ValueUnavailableFormatter(sMessageLabel);

ValueUnavailableFormatterTest.prototype.test_NullInputReturnsMessage = function() {
  var sResult = this.m_oFormatter.format(null);
  assertEquals(sResult, "Value not supplied");

ValueUnavailableFormatterTest.prototype.tearDown = function() {
  this.m_oFormatter = undefined;

To be recognized and run as a test by JSTestDriver, the function name must be prefixed with test. The setUp() method is executed before every test method. It is used to create objects that are required by all tests. The tearDown() method is used to return the browser to the same state that it was in before the test ran. This ensures tests do not interfere with each other.

Executing Your Test

You execute your test by opening a console terminal and navigating to the sdk directory of your BladeRunnerJS installation. Then type the following command:

brjs test {aspect/bladeset/blade_path} UTs