Class: TestSuite

hobs. TestSuite


new TestSuite(name [, options])

Parameters:
Name Type Argument Description
name string

The name of the test suite

options TestSuiteOptions <optional>

Extra options passed to the test suite

Extends

Methods


add(testElement)

Add a test "element" to the test suite

Parameters:
Name Type Description
testElement Array.<(hobs.TestCase|hobs.TestSuite)> | hobs.TestCase | hobs.TestSuite

The test element to add to the test suite

Returns:

Returns itself for chaining purpose

Type
hobs.TestSuite
Examples

Add a single test case to a test suite

testsuite.add(testcase1)

Add a single test suite to a test suite

testsuite.add(testsuite1)

Add multiple test elements to a test suite

testsuite.add([testcase1, testcase2, testsuite1, testcase3])

addTestCase(testcase)

Add a test case to the test suite

Parameters:
Name Type Description
testcase hobs.TestCase | hobs.TestSuite

The test element to add to the test suite

Returns:

Returns itself for chaining purpose

Type
hobs.TestSuite

addTestCases(tests)

Append an array of test cases to the test suite

Parameters:
Name Type Description
tests Array.<hobs.TestCase>

The array of test cases to add to the test suite

Returns:

Returns itself for chaining purpose

Type
hobs.TestSuite

cancel()

Cancels step execution

Inherited From:
Overrides:

clone()

Returns a clone of the TestSuite

Overrides:
Returns:
Type
hobs.TestSuite

done(state, result)

Completes step execution

Parameters:
Name Type Description
state string

The final state of the step

result object

The result of the step execution

Inherited From:
Overrides:

duration( [format])

Get the duration of the test step execution

Parameters:
Name Type Argument Default Description
format string <optional>
'ms'

Specific format to convert the duration to. By default, milliseconds

Inherited From:
Returns:

The duration of execution in a specific format. Returns -1 if the test step has not been completely executed.

Type
number

exec( [options])

Executes the step. It consists of executing the function passed to the constructor.

Parameters:
Name Type Argument Description
options Object <optional>

Extra properties, extending the ones set at the instantiation of the step and passed, as first argument, to the step function.

Inherited From:
Overrides:
Returns:

A promise

Type
Object

execData(key, value)

Get/set execution metadata of the test step

Parameters:
Name Type Description
key string

The name of the option property

value *

The value to set the option property to

Inherited From:
Example
// Init TestStep
var step = new hobs.TestStep('ts1', 'Test Step #1');
// Execution metadata is set to an empty object by default

// Get all the options as an Object
step.execData(); // => {}

// Get the value of a specific option property
step.execData('prop1'); // => 'string'
step.execData('prop2'); // => 12

// Set the value of a specific option property
step.execData('prop1', true);
step.execData('prop2', 123);
step.execData(); // => {prop1: true, prop2: 123}

executionEndHandler()


hasPassed()

Returns:

Returns true if the test suite got executed and all the test cases have passed. Returns false if any of the test case failed

Type
boolean

options(name, value)

Get/set options of the step

Parameters:
Name Type Description
name string

The name of the option property

value *

The value to set the option property to

Inherited From:
Example
// Init Step with options
var step = new hobs.Chaining.Step(null, {prop1: 'string', prop2: 12});

// Get all the options as an Object
step.options(); // => {prop1: 'string', prop2: 12}

// Get the value of a specific option property
step.options('prop1'); // => 'string'
step.options('prop2'); // => 12

// Set the value of a specific option property
step.options('prop1', true);
step.options('prop2', 123);
step.options(); // => {prop1: true, prop2: 123}

pause()

Pauses step execution

Inherited From:

result( [format] [, withDetails])

Returns a represention of the result of the test step execution.

Parameters:
Name Type Argument Default Description
format string <optional>

Use a specific hobs.reporters to render the result.

withDetails boolean <optional>
false

By default, hobs.reporters do not process children of successful test steps. Force this parameter to true to also get them.

Inherited From:
Overrides:
Returns:

An object representing the result of the execution.

Type
object

resume()

Resumes execution of a paused step

Inherited From:
Throws:

Will throw an error if the step is not paused


state()

Returns the current state of the step

Inherited From:
Returns:
Type
String