Skip to content

Instantly share code, notes, and snippets.

@jamiejackson
Last active May 5, 2016 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiejackson/24c64aa587f362e30d954266feb72e82 to your computer and use it in GitHub Desktop.
Save jamiejackson/24c64aa587f362e30d954266feb72e82 to your computer and use it in GitHub Desktop.
Example of Creating Dynamic Tests/Suites in TestBox BDD Syntax
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(). See explanation here:
* https://goo.gl/gosdBK
*/
doDynamicSuiteConfig();
/*
* @hint This function is arbitrarily named, but it sets up a var needed by the dynamic tests example
*/
function doDynamicSuiteConfig(){
variables.dynamicSuiteConfig = ["foo","bar","baz"];
}
function run( testResults, testBox ){
/*
* @hint Dynamic Test Suite 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);
});
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment