[testbox 1.0.0] nested describe function always run at end.

I am trying nested describe but some how nested one always run at the end of parent describe spec. I have tried below code to run on RAILO 4.1 (copied from documentation of testbox and added debug to see how flow work) but somehow my nested spec run at end. I think this should not be actual behavior. Please advice.

Running with url: http://localhost/test/specs/integration/BDDTest.cfc?method=runRemote

/**

  • This tests the BDD functionality in TestBox. This is CF10+, Railo4+

*/

component extends=“coldbox.system.testing.BaseSpec” appMapping="/root"{

/*********************************** LIFE CYCLE Methods ***********************************/

function beforeAll(){

coldbox = 0;

}

function afterAll(){

structClear( application );

}

/*********************************** BDD SUITES ***********************************/

function run(){

/**

  • describe() starts a suite group of spec tests.
  • Arguments:
  • @title The title of the suite, Usually how you want to name the desired behavior
  • @body A closure that will resemble the tests to execute.
  • @labels The list or array of labels this suite group belongs to
  • @asyncAll If you want to parallelize the execution of the defined specs in this suite group.
  • @skip A flag that tells TestBox to skip this suite group from testing if true

*/

describe(“A spec”, function() {

beforeEach(function( currentSpec ) {

debug(“beforeeach”);

coldbox = 22;

});

afterEach(function( currentSpec ) {

debug(“aftereach”);

coldbox = 0;

});

it(“is just a function, so it can contain any code”, function() {

debug(“first”);

expect( coldbox ).toBe( 22 );

});

it(“can have more than one expectation and talk to scopes”, function() {

debug(“second”);

expect( coldbox ).toBe( 22 );

});

describe(“nested inside a second describe”, function() {

beforeEach(function( currentSpec ) {

debug(">>beforeeach");

awesome = 22;

});

afterEach(function( currentSpec ) {

debug(">>aftereach");

awesome = 22 + 8;

});

it("can reference both scopes as needed ", function() {

debug(">>first");

expect( coldbox ).toBe( 1 );

});

});

it(“can be declared after nested suites and have access to nested variables”, function() {

debug(“third”);

expect( coldbox ).toBe( 30 );

});

});

}

private function isRailo(){

return ( structKeyExists( server, “railo” ) );

}

}

We just fixed this pritesh

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Hi Luis,
Thanks for getting back on this but I think this doesn’t resolved my problem. I was reading documentation from http://wiki.coldbox.org/wiki/TestBox.cfm where it mention below.

“In BDD, suites can be nested within each other which provides a great capability of building trees of tests. Not only does it arrange them in tree format but also TestBox will execute the life-cycle methods in order of nested suites as it traverses the tree”

If I understand it correctly it means that inner suits will execute in sequence it written in parent suits with respect to spec written in parent. for ex.

describe(“parent”,function(){
it(“first spec”,function(){});
describe(“child”,function(){
it(“first child spec”,function()());
});
it(“second spec”, function(){});
})

In this case I was expecting in following manner…

  • Parent
    first spec
  • child
    first child spec
    second spec

but ACTUAL output as follow

  • Parent
    first spec
    second spec
  • child
    first child spec

Since while reviewing code I realize that you are maintaining two separate arrays for specs and child suits where specs execute before child suit. Not sure I understand it incorrectly or it is bug. If I understand it incorrectly then sample example given in above mention documentation where ‘awesome’ variable assigned in child suits of ‘beforeEach’/‘afterEach’ function can not be used in specs of parent suit those written after child suits.

As always thanks for your great work :slight_smile:

Thanks,
Pritesh

Pritesh, the execution is not sequential like that as the second it() is part of the same suite, just defined at a later point in time. The first suite executes and then the nested suites.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Thanks for clarification. In that you may want to change example in documentation since variable name ‘awesome’ will not accessible in it() of parent.

Thanks,
Pritesh