Bunoon: JUST | Manual | Test Case Setup

TestCase() classes are the building blocks that are used to setup your tests. The class (which is supplied from TESS) inherits the $J.TestCase() class layout, allowing you to then add tests (functions), which will be run when the TestCase() is run, or run as a group of TestCase() objects.

Below you will find a description of the different functions which can be included in TestCase() classes (if required). TestCase() classes are the only area that will use these functions, but will also be run when you use the Discover() or RunSuite() modes.

You will also find some useful string tags, which can be used for printing TestCase() class descriptions, or skipping entire TestCase() classes altogether (these reasons and descriptions are printed in the report log).

This function is called before each test is called, allowing you to setup objects, settings, etc.

Below is an example of how to use this function:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


SetUp: function () {

// Add SetUp() code here.

}

} );

This function is called after each test has been run, allowing you to clear objects, settings, etc.

Below is an example of how to use this function:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


TearDown: function () {

// Add TearDown() code here.

}

} );

This function is called whenever a test is skipped.

Below is an example of how to use this function:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


TearDownSkip: function () {

// Add TearDownSkip() code here.

}

} );

This function is called whenever a test fails to execute.

Below is an example of how to use this function:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


TearDownExecutionError: function () {

// Add TearDownExecutionError() code here.

}

} );

This function is called before all the tests in the TestCase() class are run, allow you to setup an objects/variables to use between the tests.

This function can also be used to setup additional properties for the tests. These properties can be found under the "Tests" section in the left side navigation.

Below is an example of how to use this function:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


SetUpCase: function () {

// Add SetUpCase() code here.

}

} );

This function is called after all the tests in the TestCase() class have been run, allowing you clear any objects/variables that are have been used.

Below is an example of how to use this function:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


TearDownCase: function () {

// Add TearDownCase() code here.

}

} );

This function is called when a TestCase() class is skipped.

Below is an example of how to use this function:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


TearDownCaseSkip: function () {

// Add TearDownCaseSkip() code here.

}

} );

Prints a description in the report log that states what the TestCase() may be used for (this is not printed when the TestCase() is skipped).

Below is an example of how to use this string tag:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


Description: "This test case is used to check that that values are strictly equal to the specified values."

} );

Forces an entire TestCase() class to be skipped, ensuring that none of the test functions in the class are run, while printing the reason in the report log.

Below is an example of how to use this string tag:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


SkipCase: "These tests are being skipped because they are not currently working due to software re-writes"

} );

Forces an entire TestCase() class to be skipped if a specific condition is met, ensuring that none of the test functions in the class are run.

Below is an example of how to use this array tag:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


SkipCaseIf: [ (10 > 5), "These tests will be skipped because 10 is larger than 5." ]

} );

Forces an entire TestCase() class to be skipped if a specific condition is not met, ensuring that none of the test functions in the class are run.

Below is an example of how to use this array tag:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


SkipCaseUnless: [ (10 < 5), "These tests will be skipped because 10 is not smaller than 5." ]

} );

Forces an entire TestCase() class to be repeat 'x' number of times (defaults to 1 as normal), allowing cases to be retested as information is changed. If you have specified 2 repeats, the TestCase() will run and then repeat 2 times (causing the TestCase() to run 3 times in total).

Below is an example of how to use this setting:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


Repeats: 2

} );

Forces the test functions functions in a TestCase() class to run in a specific order. The names of the functions should be split up using a "," delimiter. Any functions not specified in the order will be run in their original order after the ordered function tests have been run.

Below is an example of how to use this array tag:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


Order: "test1, test2",


test1: function () {

// Setup all tests here.

},


test2: function () {

// Setup all tests here.

}

} );

States if this TestCase() class can be discovered when the test type "RunDiscover()" is used (defaults to true).

Below is an example of how to use this setting:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


AllowDiscover: false

} );

States the ID that should be used for this TestCase() instance.

Below is an example of how to use this setting:

var test = new $T.Class.New( {

_inherit_: new $J.TestCase(),


ID: "TestID1"

} );