Skip to content
Grzegorz Pabian edited this page Jul 21, 2014 · 4 revisions

Overview

Test builders are plugins used during test preparation process. They are called in following situations:

  • a user wants to list all the available tests
  • a user wants to execute a single test
  • a job is being created

Test builders are called in a pipeline receiving a data object of a single group of tests.

Structure

A typical test builder should expose a build function. For more advanced builders you can use attach and init API - check Structure of a plugin section for more details.

Example:

module.exports = {
    name: 'bender-testbuilder-example',

    build: function (data) {

        // alter the data i.e. add some new tests

        return data;
    }
};

Data object

Data object contains multiple information about a test group.

Some of them are taken from the configuration file:

  • String name - name of the group
  • String basePath - the group's base path
  • Array paths - a list of the group's paths
  • String framework - name of a test framework used in this group
  • Array applications - a list of the applications used in this group, if any

Besides the information taken from the config, there are two more important fields:

  • Array files - a list of files located in the group's paths
  • Object tests - a list of tests already created for the group, e.g. using default test builders

There could be more properties available added by custom test builders. Please check custom test builder's documentation for more details.

Example data object:

{
    applications: [ 'ago' ],
    basePath: 'tests/',
    paths: [ '/', '!assets/' ],
    tests: {
        'tests/html': {
            id: 'tests/html',
            html: 'tests/html.html',
            js: 'tests/html.js',
            tags: [ 'tests', 'html' ],
            include: '%BASE_PATH%assets/helpers.js,%BASE_PATH%assets/results.js'
        },
        'tests/script': {
            id: 'tests/script',
            js: 'tests/script.js',
            tags: [ 'tests', 'script' ],
            include: '%BASE_PATH%assets/helpers.js'
        }
    },
    name: 'Core',
    framework: 'jasmine',
    files: []
}

A test builder can alter the data object i.e. extend it, remove files from the list, modify or add new tests etc.

It should return the received data object or a promise for this object if a part of the test builder's code works asynchronously.

The promise should be compatible with Promises/A+ specification.

Clone this wiki locally