Last active
May 5, 2016 19:59
-
-
Save jamiejackson/24c64aa587f362e30d954266feb72e82 to your computer and use it in GitHub Desktop.
Example of Creating Dynamic Tests/Suites in TestBox BDD Syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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