Skip to content

Commit

Permalink
TESTBOX-320 #resolve
Browse files Browse the repository at this point in the history
Runner tries to instantiate abstract classes
  • Loading branch information
lmajano committed Jun 16, 2021
1 parent 8eb5461 commit a5639a7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
31 changes: 26 additions & 5 deletions system/TestBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ component accessors="true" {
if ( getComponentMetadata( thisBundlePath ).type eq "interface" ) {
continue;
}

// Execute Bundle
testBundle(
bundlePath = thisBundlePath,
Expand Down Expand Up @@ -546,14 +547,21 @@ component accessors="true" {
* @bundlePath The path of the Bundle CFC to test.
* @testResults The testing results object to keep track of results
* @callbacks The callbacks struct or CFC
*
* @throws BundleRunnerMajorException
*/
private function testBundle(
required bundlePath,
required testResults,
required callbacks
){
// create new target bundle and get its metadata
var target = getBundle( arguments.bundlePath );
try{
var target = getBundle( arguments.bundlePath );
} catch( "AbstractComponentException" e ){
// Skip abstract components
return this;
}

// verify call backs
if ( structKeyExists( arguments.callbacks, "onBundleStart" ) ) {
Expand Down Expand Up @@ -604,13 +612,26 @@ component accessors="true" {

/**
* Creates and returns a bundle CFC with spec capabilities if not inherited.
*
* @bundlePath The path to the Bundle CFC
*
* @throws AbstractComponentException - When an abstract component exists as a spec
*/
private any function getBundle( required bundlePath ){
var bundle = createObject(
"component",
"#arguments.bundlePath#"
);
try{
var bundle = createObject(
"component",
"#arguments.bundlePath#"
);
} catch( "Application" e ){
if( findNoCase( "abstract component", e.message ) ){
throw(
type : "AbstractComponentException",
message : "Skip abstract components"
);
}
rethrow;
}
var familyPath = "testbox.system.BaseSpec";

// check if base spec assigned
Expand Down
11 changes: 11 additions & 0 deletions tests/specs/AbstractClass.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
abstract component{

function init(){
// This is an abstract class
}

function run(){

}

}

0 comments on commit a5639a7

Please sign in to comment.