Skip to content

Instantly share code, notes, and snippets.

@dskaggs
Last active August 29, 2015 14:04
Show Gist options
  • Save dskaggs/757bb41915fdb7e5ef1b to your computer and use it in GitHub Desktop.
Save dskaggs/757bb41915fdb7e5ef1b to your computer and use it in GitHub Desktop.
BDD Test Suite Question
component extends="testbox.system.BaseSpec"{
/*********************************** LIFE CYCLE Methods ***********************************/
// executes before all suites+specs in the run() method
function beforeAll(){
variables.theObject = new path.to.Object( argumentCollection=arguments );
}
// executes after all suites+specs in the run() method
function afterAll(){
structDelete( variables, 'theObject' );
}
/*********************************** BDD SUITES ***********************************/
function run(){
// test suite for init() method
describe( 'The init() function ...', function(){
// before each spec in this suite group
beforeEach( function(){
});
// after each spec in this suite group
afterEach( function(){
});
it( '... returns a reference to itself', function(){
expect( theObject ).toBeInstanceOf( 'path.to.Object' );
});
});
//test suite for the method1() method
describe( 'The method1() function...', function(){
// before each spec in this suite group
beforeEach( function(){
result = theObject.method1( argumentCollection={});
});
// after each spec in this suite group
afterEach( function(){
});
it( '... returns a structure of values', function( result ){
expect( result ).toBeStruct();
});
it( '... returns no errors', function( result ){
expect( result.errors ).notToBeStruct();
});
it( '... returns a sucessful status', function( result ){
expect( result.status ).toBe( 1 );
});
});
//test suite for the method2() method
describe( 'The method2() function...', function(){
// before each spec in this suite group
beforeEach( function(){
result = theObject.method2( argumentCollection={});
});
// after each spec in this suite group
afterEach( function(){
});
it( '... returns a structure of values', function( result ){
expect( isStruct( result ) ).toBeTrue();
});
it( '... returns no errors', function( result ){
expect( result.errors ).notToBeStruct();
});
it( '... returns a sucessful status', function( result ){
expect( result.status ).toBe( 1 );
});
it( '... returns an array of stuff', function( result ){
expect( structKeyExists( result, "stuff" ) AND isArray( result.stuff ) AND arrayLen( result.stuff ) ).toBeTrue();
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment