Bunoon: JUST | Manual | Tests

Tests are functions that are setup inside your TestCase() class, which are run as single items when the TestCase() class is run, or run when included in a group of TestCase() objects.

Below you will find a list of the different properties that can be set for tests, which will allow you greater flexibility on how the tests are handled and run. These properties can be assigned from the "SetUpCase" function, or from other tests or tear down functions, allowing you greater control over the entire TestCase().

Always skips the test, printing the reason specified in the report.

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.SkipTest = "This is an example of a skipped test";

},


test: function () {

// Setup assert tests here.

}

} );

Skips the test if the specific condition is met.

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.SkipTestIf = [ (10 > 5), "This test will be skipped because 10 is larger than 5." ];

},


test: function () {

// Setup assert tests here.

}

} );

Always skips the test unless the specific condition is met.

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.SkipTestUnless = [ (10 < 5), "This test will be skipped because 10 is not smaller than 5." ];

},


test: function () {

// Setup assert tests here.

}

} );

States a description of the test that is printed in the report under the test header.

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.Description = "An example of a description for a test.";

},


test: function () {

// Setup assert tests here.

}

} );

States what the expected result of the test should be (Passed/Failed counts will not be updated if the expected result is met).

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.ExpectedFailure = false;

},


test: function () {

// Setup assert tests here.

}

} );

States the total number of times the test should be repeated after the initial run.

  • Default: 0.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.Repeats = 1;

},


test: function () {

// Setup assert tests here.

}

} );

Overrides the result of the test to the value specified (Passed/Failed counts will be updated accordingly). This should only be used from "SetUpCase()" of the test function itself.

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test8.Passed = false;

},


test: function () {

// Setup assert tests here.

}

} );

States if a function is a test or not (if set to false, it will not be run or included in the summary).

  • Default: true.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.IsTest = false;

},


test: function () {

// This function will not be called as a test.

}

} );

States a custom SetUp function that should be called before the test runs (overrides the TestCase() "SetUp" function).

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.SetUp = function () { console.log( "This is a custom SetUp function for a test." ) };

},


test: function () {

// Setup assert tests here.

}

} );

States a custom TearDown function that should be called after the test runs (overrides the TestCase() "TearDown" function).

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.TearDown = function () { console.log( "This is a custom TearDown function for a test." ) };

},


test: function () {

// Setup assert tests here.

}

} );

States the maximum duration this test should run before its marked as a failure (in seconds).

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.MaximumDuration = 0.5;

},


test: function () {

// Setup assert tests here.

}

} );

States if a test should be run in isolated mode, preventing any SetUp or TearDown functions being run around it (including custom set ones).

  • Default: false.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.Isolated = true;

},


test: function () {

// Setup assert tests here.

}

} );

States a set of parameters that should be used against a specific test. Using an array of objects, you can force a test to run 'x' number of times with different values to test.

  • Default: null.

Below is an example of how to use this property:

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

_inherit_: new $J.TestCase(),


SetUpCase: function () {

this.test.Cases = [

{

Value: 1,

Equals: 1

},

{

Value: 2,

Equals: 2

},

{

Value: 3,

Equals: 3

},

{

Value: 4,

Equals: 4

}

];

},


test: function ( oParameters ) {

this.Assert.StrictEqual( oParameters.Value, oParameters.Equals );

}

} );