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” ) );
}
}