Dynamic Suites
Example
component
extends="testbox.system.BaseSpec"
hint="This is an example of a TestBox BDD test bundle containing dynamically-defined suites."
{
/*
* Need to do config for *dynamic* test suites here, in the
* pseudo-constructor, versus in `beforeAll()`.
*/
doDynamicSuiteConfig();
/*
* @hint This method is arbitrarily named, but it sets up
* metadata needed by the dynamic suites example. The setup
* could have been done straight in the pseudo-constructor,
* but it might be nice to organize it into such a method
* as this.
*/
function doDynamicSuiteConfig(){
variables.dynamicSuiteConfig = ["foo","bar","baz"];
}
function run( testResults, testBox ){
/*
* @hint Dynamic Test Suites Example
*/
// loop over test metadata
for ( var thing in dynamicSuiteConfig ) {
describe("Dynamic Suite #thing#", function(){
// notice how data is passed into the it() closure:
// * data={ keyA=valueA, keyB=ValueB }
// * function( data )
it( title=thing & "test",
data={ thing=thing },
body=function( data ) {
var thing = data.thing;
expect( thing ).toBe( thing );
});
});
}
}
}Last updated
Was this helpful?