From b663c41514613a9d66be90edda99d2fdc601ce19 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Tue, 28 Apr 2020 12:10:36 -0500 Subject: [PATCH 01/11] version bump --- box.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/box.json b/box.json index 9184b231..cd81fae1 100644 --- a/box.json +++ b/box.json @@ -1,6 +1,6 @@ { "name":"TestBox", - "version":"4.0.0", + "version":"4.1.0", "location":"https://downloads.ortussolutions.com/ortussolutions/testbox/@build.version@/testbox-@build.version@.zip", "author":"Ortus Solutions ", "slug":"testbox", From c4bcd48a51c0a16bfc3034e037659bd7418b39a6 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 7 May 2020 13:45:20 -0500 Subject: [PATCH 02/11] TESTBOX-282 #resolve Added cfml engine and version as part of the test results as properties --- system/TestResult.cfc | 54 +++++++++++++++++++------------- system/reports/assets/simple.cfm | 4 +-- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/system/TestResult.cfc b/system/TestResult.cfc index 533a6f5b..5c4cc3ca 100644 --- a/system/TestResult.cfc +++ b/system/TestResult.cfc @@ -23,7 +23,7 @@ component accessors="true" { property name="excludes" type="array"; // bundle stats - property name="bundleStats" type="struct"; + property name="bundleStats" type="array"; // bundles, suites and specs only values that can execute property name="testBundles" type="array"; @@ -34,14 +34,19 @@ component accessors="true" { property name="coverageEnabled" type="boolean"; property name="coverageData" type="struct"; + // CFML Engine Information + property name="CFMLEngine"; + property name="CFMLEngineVersion"; + /** * Constructor - * @bundleCount.hint the count to init the results for - * @labels.hint The labels to use - * @testBundles.hint The test bundles that should execute ONLY - * @testSuites.hint The test suites that should execute ONLY - * @testSpecs.hint The test specs that should execute ONLY + * + * @bundleCount the count to init the results for + * @labels The labels to use + * @testBundles The test bundles that should execute ONLY + * @testSuites The test suites that should execute ONLY + * @testSpecs The test specs that should execute ONLY */ TestResult function init( numeric bundleCount = 0, @@ -87,6 +92,12 @@ component accessors="true" { variables.coverageEnabled = false; variables.coverageData = {}; + // CFML Engine + Version + variables.CFMLEngine = server.coldfusion.productName; + variables.CFMLEngineVersion = ( + structKeyExists( server, "lucee" ) ? server.lucee.version : server.coldfusion.productVersion + ); + return this; } @@ -135,7 +146,7 @@ component accessors="true" { /** * Increment a global stat - * @type.hint The type of stat to increment: fail,pass,error or skipped + * @type The type of stat to increment: fail,pass,error or skipped */ TestResult function incrementStat( required type = "pass", numeric count = 1 ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { @@ -210,7 +221,7 @@ component accessors="true" { /** * End processing of a bundle stats reference - * @stats.hint The bundle stats structure reference to complete + * @stats The bundle stats structure reference to complete */ TestResult function endStats( required struct stats ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { @@ -222,7 +233,7 @@ component accessors="true" { /** * Get a bundle stats by path as a struct or the entire stats array if no path passed. - * @id.hint If passed, then retrieve by id + * @id If passed, then retrieve by id */ any function getBundleStats( string id ){ lock name="tb-results-#variables.resultsID#" type="readonly" timeout="10" { @@ -247,9 +258,9 @@ component accessors="true" { /** * Start a new suite stats and return its reference - * @name.hint The name of the suite - * @bundleStats.hint The bundle stats reference this belongs to. - * @parentStats.hint If passed, the parent stats this suite belongs to + * @name The name of the suite + * @bundleStats The bundle stats reference this belongs to. + * @parentStats If passed, the parent stats this suite belongs to */ struct function startSuiteStats( required string name, @@ -310,7 +321,7 @@ component accessors="true" { /** * Get a suite stats by id from the reverse lookup - * @id.hint Retrieve by id + * @id Retrieve by id */ any function getSuiteStats( required string id ){ lock name="tb-results-#variables.resultsID#" type="readonly" timeout="10" { @@ -320,8 +331,8 @@ component accessors="true" { /** * Start a new spec stats and return its reference - * @name.hint The name of the suite - * @suiteStats.hint The suite stats reference this belongs to. + * @name The name of the suite + * @suiteStats The suite stats reference this belongs to. */ struct function startSpecStats( required string name, required struct suiteStats ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { @@ -363,8 +374,8 @@ component accessors="true" { /** * Record a spec stat with its recursive chain - * @type.hint The type of stat to store: skipped,fail,error,pass - * @specStats.hint The spec stats to increment + * @type The type of stat to store: skipped,fail,error,pass + * @specStats The spec stats to increment */ function incrementSpecStat( required string type, required struct stats ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { @@ -400,13 +411,12 @@ component accessors="true" { "totalFail", "totalError", "totalSkipped", - "bundleStats" + "bundleStats", + "CFMLEngine", + "CFMLEngineVersion" ]; + var result = { - "CFMLEngine" : server.coldfusion.productName, - "CFMLEngineVersion" : ( - structKeyExists( server, "lucee" ) ? server.lucee.version : server.coldfusion.productVersion - ), "coverage" : {} }; diff --git a/system/reports/assets/simple.cfm b/system/reports/assets/simple.cfm index 694d8c95..870a9e27 100644 --- a/system/reports/assets/simple.cfm +++ b/system/reports/assets/simple.cfm @@ -87,8 +87,8 @@
- #server.coldfusion.productName# - #structKeyExists( server, "lucee" ) ? server.lucee.version : server.coldfusion.productVersion# + #results.getCFMLEngine()# + #results.getCFMLEngineVersion()#
From 52cd637b86f196dfe97d1eb4eaa17ca9dc843ff2 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 7 May 2020 14:30:49 -0500 Subject: [PATCH 03/11] TESTBOX-284 #resolve Update all reporters so they can just build and return the report with no content type or context repsonse resets --- system/reports/ANTJUnitReporter.cfc | 19 ++++++++++--------- system/reports/BaseReporter.cfc | 7 +++++++ system/reports/CodexWikiReporter.cfc | 23 ++++++++++++----------- system/reports/ConsoleReporter.cfc | 18 ++++++++++++------ system/reports/DocReporter.cfc | 21 +++++++++++---------- system/reports/DotReporter.cfc | 11 +++++++---- system/reports/IReporter.cfc | 11 +++++++---- system/reports/JSONReporter.cfc | 22 ++++++++++++---------- system/reports/JUnitReporter.cfc | 21 +++++++++++---------- system/reports/MinReporter.cfc | 21 +++++++++++---------- system/reports/MinTextReporter.cfc | 21 +++++++++++---------- system/reports/RawReporter.cfc | 14 +++++++------- system/reports/SimpleReporter.cfc | 22 ++++++++++++---------- system/reports/TapReporter.cfc | 22 ++++++++++++---------- system/reports/TextReporter.cfc | 22 ++++++++++++---------- system/reports/XMLReporter.cfc | 19 +++++++++++++------ 16 files changed, 167 insertions(+), 127 deletions(-) diff --git a/system/reports/ANTJUnitReporter.cfc b/system/reports/ANTJUnitReporter.cfc index 4943243e..c39cef08 100644 --- a/system/reports/ANTJUnitReporter.cfc +++ b/system/reports/ANTJUnitReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,16 +17,21 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specifc browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean justReturn=false ){ - getPageContextResponse().setContentType( "application/xml" ); + if( !arguments.justReturn ){ + getPageContextResponse().setContentType( "application/xml" ); + } return toJUnit( arguments.results ); } diff --git a/system/reports/BaseReporter.cfc b/system/reports/BaseReporter.cfc index 3085ddfd..6086032d 100644 --- a/system/reports/BaseReporter.cfc +++ b/system/reports/BaseReporter.cfc @@ -6,6 +6,13 @@ */ component { + /** + * Constructor + */ + function init(){ + return this; + } + /** * Helper method to deal with ACF2016's overload of the page context response, come on Adobe, get your act together! */ diff --git a/system/reports/CodexWikiReporter.cfc b/system/reports/CodexWikiReporter.cfc index 226a71fd..2c412821 100644 --- a/system/reports/CodexWikiReporter.cfc +++ b/system/reports/CodexWikiReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -20,18 +16,23 @@ component extends="BaseReporter" { /** * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any - * Specifc browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * Specific browser types if needed. + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/text" ); + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/text" ); + } // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/ConsoleReporter.cfc b/system/reports/ConsoleReporter.cfc index 76f508e6..dc072d0e 100644 --- a/system/reports/ConsoleReporter.cfc +++ b/system/reports/ConsoleReporter.cfc @@ -22,17 +22,23 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/plain" ); + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/plain" ); + } + // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/DocReporter.cfc b/system/reports/DocReporter.cfc index 066c816e..c96d27f3 100644 --- a/system/reports/DocReporter.cfc +++ b/system/reports/DocReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,22 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/html" ); + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/html" ); + } // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/DotReporter.cfc b/system/reports/DotReporter.cfc index 071c5fc7..c0cc57cb 100644 --- a/system/reports/DotReporter.cfc +++ b/system/reports/DotReporter.cfc @@ -21,14 +21,17 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/IReporter.cfc b/system/reports/IReporter.cfc index 44699a70..2bffc718 100644 --- a/system/reports/IReporter.cfc +++ b/system/reports/IReporter.cfc @@ -15,14 +15,17 @@ interface { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean justReturn=false ); } diff --git a/system/reports/JSONReporter.cfc b/system/reports/JSONReporter.cfc index 620a5d53..8dddb983 100644 --- a/system/reports/JSONReporter.cfc +++ b/system/reports/JSONReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,23 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - resetHTMLResponse(); - getPageContextResponse().setContentType( "application/json" ); + if( !arguments.justReport ){ + resetHTMLResponse(); + getPageContextResponse().setContentType( "application/json" ); + } + return serializeJSON( arguments.results.getMemento() ); } diff --git a/system/reports/JUnitReporter.cfc b/system/reports/JUnitReporter.cfc index e008fa27..277f366c 100644 --- a/system/reports/JUnitReporter.cfc +++ b/system/reports/JUnitReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,22 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - resetHTMLResponse(); - getPageContextResponse().setContentType( "application/xml" ); + if( !arguments.justReport ){ + resetHTMLResponse(); + getPageContextResponse().setContentType( "application/xml" ); + } return toJUnit( arguments.results ); } diff --git a/system/reports/MinReporter.cfc b/system/reports/MinReporter.cfc index 91fba3c3..11233d0b 100644 --- a/system/reports/MinReporter.cfc +++ b/system/reports/MinReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,22 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/html" ); + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/html" ); + } // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/MinTextReporter.cfc b/system/reports/MinTextReporter.cfc index 346a414c..5475b23d 100644 --- a/system/reports/MinTextReporter.cfc +++ b/system/reports/MinTextReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,22 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/plain" ); + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/plain" ); + } // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/RawReporter.cfc b/system/reports/RawReporter.cfc index 33652f6b..3105f7b9 100644 --- a/system/reports/RawReporter.cfc +++ b/system/reports/RawReporter.cfc @@ -6,9 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } /** * Get the name of the reporter @@ -21,14 +18,17 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ return arguments.results.getMemento(); } diff --git a/system/reports/SimpleReporter.cfc b/system/reports/SimpleReporter.cfc index c2e06ba3..da72e2a1 100644 --- a/system/reports/SimpleReporter.cfc +++ b/system/reports/SimpleReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,23 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/html" ); + + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/html" ); + } // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/TapReporter.cfc b/system/reports/TapReporter.cfc index a9a3f3dd..caf4ab42 100644 --- a/system/reports/TapReporter.cfc +++ b/system/reports/TapReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,23 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/plain" ); + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/plain" ); + } + // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/TextReporter.cfc b/system/reports/TextReporter.cfc index d33634b5..cd364dd4 100644 --- a/system/reports/TextReporter.cfc +++ b/system/reports/TextReporter.cfc @@ -6,10 +6,6 @@ */ component extends="BaseReporter" { - function init(){ - return this; - } - /** * Get the name of the reporter */ @@ -21,17 +17,23 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean arguments.justReport = false ){ - // content type - getPageContextResponse().setContentType( "text/plain" ); + if( !arguments.justReport ){ + // content type + getPageContextResponse().setContentType( "text/plain" ); + } + // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/XMLReporter.cfc b/system/reports/XMLReporter.cfc index f09569b2..6d22569f 100644 --- a/system/reports/XMLReporter.cfc +++ b/system/reports/XMLReporter.cfc @@ -6,6 +6,9 @@ */ component extends="BaseReporter" { + /** + * Constructor + */ function init(){ variables.converter = new testbox.system.util.XMLConverter(); return this; @@ -22,17 +25,21 @@ component extends="BaseReporter" { * Do the reporting thing here using the incoming test results * The report should return back in whatever format they desire and should set any * Specific browser types if needed. - * @results.hint The instance of the TestBox TestResult object to build a report on - * @testbox.hint The TestBox core object - * @options.hint A structure of options this reporter needs to build the report with + * @results The instance of the TestBox TestResult object to build a report on + * @testbox The TestBox core object + * @options A structure of options this reporter needs to build the report with + * @justReturn Boolean flag that if set just returns the content with no content type and buffer reset */ any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {} + struct options = {}, + boolean justReturn = false ){ - resetHTMLResponse(); - getPageContextResponse().setContentType( "application/xml" ); + if( !arguments.justReturn ){ + resetHTMLResponse(); + getPageContextResponse().setContentType( "application/xml" ); + } return variables.converter.toXML( data = arguments.results.getMemento(), rootName = "TestBox" ); } From dc4f7fcc0e0bd8f27612c44cc7acf2163fc87cbb Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 7 May 2020 14:44:41 -0500 Subject: [PATCH 04/11] TESTBOX-285 #resolve make buildReporter public in the testbox core --- system/TestBox.cfc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/TestBox.cfc b/system/TestBox.cfc index 2ce9db73..462ae8a8 100644 --- a/system/TestBox.cfc +++ b/system/TestBox.cfc @@ -454,9 +454,10 @@ component accessors="true" { /** * Build a reporter according to passed in reporter type or class path + * * @reporter The reporter type to build. */ - private any function buildReporter( required reporter ){ + any function buildReporter( required reporter ){ switch ( arguments.reporter ) { case "json": { return new "testbox.system.reports.JSONReporter"( ); From 6120c413918bc7f6fd8e9c00c0d46fc0cf2e783e Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 7 May 2020 14:54:41 -0500 Subject: [PATCH 05/11] fixed arguments on reporters --- system/reports/CodexWikiReporter.cfc | 4 ++-- system/reports/ConsoleReporter.cfc | 4 ++-- system/reports/DocReporter.cfc | 4 ++-- system/reports/DotReporter.cfc | 2 +- system/reports/JSONReporter.cfc | 4 ++-- system/reports/JUnitReporter.cfc | 4 ++-- system/reports/MinReporter.cfc | 4 ++-- system/reports/MinTextReporter.cfc | 4 ++-- system/reports/RawReporter.cfc | 2 +- system/reports/SimpleReporter.cfc | 4 ++-- system/reports/TapReporter.cfc | 4 ++-- system/reports/TextReporter.cfc | 4 ++-- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/system/reports/CodexWikiReporter.cfc b/system/reports/CodexWikiReporter.cfc index 2c412821..970335f3 100644 --- a/system/reports/CodexWikiReporter.cfc +++ b/system/reports/CodexWikiReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/text" ); } diff --git a/system/reports/ConsoleReporter.cfc b/system/reports/ConsoleReporter.cfc index dc072d0e..3611e30b 100644 --- a/system/reports/ConsoleReporter.cfc +++ b/system/reports/ConsoleReporter.cfc @@ -32,9 +32,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/plain" ); } diff --git a/system/reports/DocReporter.cfc b/system/reports/DocReporter.cfc index c96d27f3..8f19349e 100644 --- a/system/reports/DocReporter.cfc +++ b/system/reports/DocReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/html" ); } diff --git a/system/reports/DotReporter.cfc b/system/reports/DotReporter.cfc index c0cc57cb..9bad04f4 100644 --- a/system/reports/DotReporter.cfc +++ b/system/reports/DotReporter.cfc @@ -31,7 +31,7 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ // bundle stats variables.bundleStats = arguments.results.getBundleStats(); diff --git a/system/reports/JSONReporter.cfc b/system/reports/JSONReporter.cfc index 8dddb983..387e2672 100644 --- a/system/reports/JSONReporter.cfc +++ b/system/reports/JSONReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ resetHTMLResponse(); getPageContextResponse().setContentType( "application/json" ); } diff --git a/system/reports/JUnitReporter.cfc b/system/reports/JUnitReporter.cfc index 277f366c..085a2c06 100644 --- a/system/reports/JUnitReporter.cfc +++ b/system/reports/JUnitReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ resetHTMLResponse(); getPageContextResponse().setContentType( "application/xml" ); } diff --git a/system/reports/MinReporter.cfc b/system/reports/MinReporter.cfc index 11233d0b..cee05918 100644 --- a/system/reports/MinReporter.cfc +++ b/system/reports/MinReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/html" ); } diff --git a/system/reports/MinTextReporter.cfc b/system/reports/MinTextReporter.cfc index 5475b23d..ccb1fac3 100644 --- a/system/reports/MinTextReporter.cfc +++ b/system/reports/MinTextReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/plain" ); } diff --git a/system/reports/RawReporter.cfc b/system/reports/RawReporter.cfc index 3105f7b9..bfe63c84 100644 --- a/system/reports/RawReporter.cfc +++ b/system/reports/RawReporter.cfc @@ -28,7 +28,7 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ return arguments.results.getMemento(); } diff --git a/system/reports/SimpleReporter.cfc b/system/reports/SimpleReporter.cfc index da72e2a1..ecfebbd9 100644 --- a/system/reports/SimpleReporter.cfc +++ b/system/reports/SimpleReporter.cfc @@ -27,10 +27,10 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/html" ); } diff --git a/system/reports/TapReporter.cfc b/system/reports/TapReporter.cfc index caf4ab42..2ffd1ef2 100644 --- a/system/reports/TapReporter.cfc +++ b/system/reports/TapReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/plain" ); } diff --git a/system/reports/TextReporter.cfc b/system/reports/TextReporter.cfc index cd364dd4..0b44a732 100644 --- a/system/reports/TextReporter.cfc +++ b/system/reports/TextReporter.cfc @@ -27,9 +27,9 @@ component extends="BaseReporter" { required testbox.system.TestResult results, required testbox.system.TestBox testbox, struct options = {}, - boolean arguments.justReport = false + boolean justReturn = false ){ - if( !arguments.justReport ){ + if( !arguments.justReturn ){ // content type getPageContextResponse().setContentType( "text/plain" ); } From 4e97b47889353f728a8e02891fe1925d7e210ab9 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 7 May 2020 15:20:41 -0500 Subject: [PATCH 06/11] small update when debug buffer doesn't exist --- system/reports/assets/simple.cfm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/reports/assets/simple.cfm b/system/reports/assets/simple.cfm index 870a9e27..591e3d03 100644 --- a/system/reports/assets/simple.cfm +++ b/system/reports/assets/simple.cfm @@ -256,7 +256,7 @@ - +
  • - + \ No newline at end of file From 6fca6f591d4c22a951a676fad7dcb21e0bfe6035 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 7 May 2020 15:38:21 -0500 Subject: [PATCH 07/11] TESTBOX-285 #resolve make buildReporter public in the testbox core --- system/TestResult.cfc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/system/TestResult.cfc b/system/TestResult.cfc index 5c4cc3ca..eb637278 100644 --- a/system/TestResult.cfc +++ b/system/TestResult.cfc @@ -423,14 +423,16 @@ component accessors="true" { // Do simple properties only for ( var thisProp in pList ) { if ( structKeyExists( variables, thisProp ) ) { + + result[ thisProp ] = variables[ thisProp ]; + // Do we need to strip out the buffer? if ( thisProp == "bundleStats" && !arguments.includeDebugBuffer ) { - for ( var thisKey in variables[ thisProp ] ) { - structDelete( thisKey, "debugBuffer" ); + for( var thisStat in result.bundleStats ){ + thisStat.debugBuffer = []; } } - result[ thisProp ] = variables[ thisProp ]; } else { result[ thisProp ] = ""; } @@ -458,4 +460,4 @@ component accessors="true" { return result; } -} +} \ No newline at end of file From ed524ba167b74b9572d6ea157ea90508c00fee01 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 7 May 2020 15:57:52 -0500 Subject: [PATCH 08/11] TESTBOX-281 #resolve request.testbox: Component ... has no accessible Member with name [$TESTID] --- system/BaseSpec.cfc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system/BaseSpec.cfc b/system/BaseSpec.cfc index 8ab032af..e842c5ca 100644 --- a/system/BaseSpec.cfc +++ b/system/BaseSpec.cfc @@ -47,6 +47,7 @@ component { "print" : variables.print, "println" : variables.println }; + request.$testID = this.$testID; } /************************************** BDD & EXPECTATIONS METHODS *********************************************/ @@ -1329,7 +1330,7 @@ component { } // lock and add - lock name="tb-debug-#this.$testID#" type="exclusive" timeout="10" { + lock name="tb-debug-#request.$testID#" type="exclusive" timeout="10" { // duplication control var newVar = ( arguments.deepCopy ? duplicate( arguments.var ) : arguments.var ); // compute label? @@ -1354,7 +1355,7 @@ component { * Clear the debug array buffer */ any function clearDebugBuffer(){ - lock name="tb-debug-#this.$testID#" type="exclusive" timeout="10" { + lock name="tb-debug-#request.$testID#" type="exclusive" timeout="10" { arrayClear( this.$debugBuffer ); } return this; @@ -1364,7 +1365,7 @@ component { * Get the debug array buffer from scope */ array function getDebugBuffer(){ - lock name="tb-debug-#this.$testID#" type="readonly" timeout="10" { + lock name="tb-debug-#request.$testID#" type="readonly" timeout="10" { return this.$debugBuffer; } } From 77bd80a4bd0ef02fdee10b2e87962f6a4a5818f9 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Wed, 27 May 2020 18:21:05 -0500 Subject: [PATCH 09/11] added changelog and asset publishing before we release --- .travis.yml | 17 +++++++++++++++++ changelog.md | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 changelog.md diff --git a/.travis.yml b/.travis.yml index e7dd30df..5639484a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ install: script: # Set Current Version - TARGET_VERSION=`cat $TRAVIS_BUILD_DIR/box.json | jq '.version' -r` + - TRAVIS_TAG=${TARGET_VERSION} - echo "Starting build TestBox v${TARGET_VERSION}" # Replace version so builder can issue it - box package set version=@build.version@+@build.number@ @@ -86,6 +87,22 @@ deploy: upload-dir: testbox/$TARGET_VERSION acl: public_read + # Github Release only on Master + - provider: releases + api_key: ${GITHUB_TOKEN} + on: + branch: + - master + condition: "$ENGINE = lucee@5" + skip_cleanup: true + edge: true + file_glob: true + file: $TRAVIS_BUILD_DIR/artifacts/testbox/**/* + release_notes_file: changelog.md + name: v${TRAVIS_TAG} + tag_name: v${TRAVIS_TAG} + overwrite: true + after_deploy: - cd $TRAVIS_BUILD_DIR/build-testbox/testbox - if [ ${ENGINE} = 'lucee@5' ]; then box forgebox publish; fi diff --git a/changelog.md b/changelog.md new file mode 100644 index 00000000..178955d5 --- /dev/null +++ b/changelog.md @@ -0,0 +1,22 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +---- + +## [4.1.0] => 2020-MAY-27 + +### Fixed + +* [TESTBOX-283] - Fix type on test results for bundlestats +* [TESTBOX-286] - `DebugBuffer` was being removed instead of resetting to empty for `getMemento` +* [TESTBOX-281] - `request.testbox` Component ... has no accessible Member with name [$TESTID] + +### Added + +* [TESTBOX-282] - Added cfml engine and version as part of the test results as properties +* [TESTBOX-284] - Update all reporters so they can just build and return the report with no content type or context repsonse resets +* [TESTBOX-285] - make `buildReporter` public in the testbox core From ef9e3ac1f1dd9e93099fd18201fd87bf8dd4a395 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Wed, 27 May 2020 18:22:37 -0500 Subject: [PATCH 10/11] updated new release script --- .cfformat.json | 7 ++++--- box.json | 5 +++-- build/{toMaster.boxr => release.boxr} | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) rename build/{toMaster.boxr => release.boxr} (96%) diff --git a/.cfformat.json b/.cfformat.json index ff8178cc..0233515e 100644 --- a/.cfformat.json +++ b/.cfformat.json @@ -17,19 +17,19 @@ "function_call.multiline.leading_comma.padding": true, "function_call.casing.builtin": "cfdocs", "function_call.casing.userdefined": "camel", - "function_call.multiline.element_count": 3, + "function_call.multiline.element_count": 2, "function_call.multiline.leading_comma": false, "function_call.multiline.min_length": 40, "function_declaration.padding": true, "function_declaration.empty_padding": false, "function_declaration.multiline.leading_comma": false, "function_declaration.multiline.leading_comma.padding": true, - "function_declaration.multiline.element_count": 3, + "function_declaration.multiline.element_count": 2, "function_declaration.multiline.min_length": 40, "function_declaration.group_to_block_spacing": "compact", "function_anonymous.empty_padding": false, "function_anonymous.group_to_block_spacing": "compact", - "function_anonymous.multiline.element_count": 3, + "function_anonymous.multiline.element_count": 2, "function_anonymous.multiline.leading_comma": false, "function_anonymous.multiline.leading_comma.padding": true, "function_anonymous.multiline.min_length": 40, @@ -44,6 +44,7 @@ "max_columns": 120, "metadata.multiline.element_count": 3, "metadata.multiline.min_length": 40, + "method_call.chain.multiline" : 3, "newline":"\n", "property.multiline.element_count": 3, "property.multiline.min_length": 40, diff --git a/box.json b/box.json index cd81fae1..38e3f2e0 100644 --- a/box.json +++ b/box.json @@ -44,9 +44,10 @@ "mockdatacfc":"system/modules/mockdatacfc/" }, "scripts":{ - "toMaster":"recipe build/toMaster.boxr", + "release":"recipe build/release.boxr", "format":"cfformat run system/**/*.cfc,test-harness/**/*.cfc,tests/specs/**/*.cfc,*.cfc --overwrite", - "format:check":"cfformat run system/**/*.cfc,test-harness/**/*.cfc,tests/specs/**/*.cfc,*.cfc --check", + "format:check":"cfformat run system/**/*.cfc,test-harness/**/*.cfc,tests/specs/**/*.cfc,*.cfc --check", + "format:watch":"cfformat watch system/**/*.cfc,test-harness/**/*.cfc,tests/specs/**/*.cfc,*.cfc ./.cfformat.json", "start:lucee":"server start serverConfigFile=server-lucee@5.json", "start:2016":"server start serverConfigFile=server-adobe@2016.json", "start:2018":"server start serverConfigFile=server-adobe@2018.json" diff --git a/build/toMaster.boxr b/build/release.boxr similarity index 96% rename from build/toMaster.boxr rename to build/release.boxr index f431e7f5..e44b9c63 100644 --- a/build/toMaster.boxr +++ b/build/release.boxr @@ -2,7 +2,7 @@ # Check out master !git checkout -f master -!git pull +!git pull origin master # Merge development into it !git merge --no-ff development # Tag the master repo with the version in box.json From 8642666f455d45d4760c6c82cbe379d06a1c0c32 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Wed, 27 May 2020 18:24:04 -0500 Subject: [PATCH 11/11] new formatting rules --- system/Assertion.cfc | 68 ++++- system/BaseSpec.cfc | 253 +++++++++++++----- system/CollectionExpectation.cfc | 5 +- system/Expectation.cfc | 37 ++- system/MockBox.cfc | 29 +- system/TestBox.cfc | 65 ++++- system/TestResult.cfc | 52 ++-- system/compat/framework/Results.cfc | 5 +- system/compat/framework/TestCase.cfc | 87 ++++-- system/compat/framework/TestSuite.cfc | 35 ++- system/compat/runner/DirectoryTestSuite.cfc | 11 +- system/compat/runner/Results.cfc | 5 +- system/coverage/CoverageService.cfc | 20 +- system/coverage/browser/CodeBrowser.cfc | 5 +- system/coverage/data/CoverageGenerator.cfc | 21 +- system/coverage/data/PathPatternMatcher.cfc | 10 +- .../coverage/data/TemplateCompiler_Lucee.cfc | 5 +- system/coverage/sonarQube/SonarQube.cfc | 10 +- system/mockutils/MockGenerator.cfc | 32 ++- system/mockutils/Stub.cfc | 2 +- system/reports/ANTJUnitReporter.cfc | 39 +-- system/reports/BaseReporter.cfc | 5 +- system/reports/CodexWikiReporter.cfc | 4 +- system/reports/ConsoleReporter.cfc | 4 +- system/reports/DocReporter.cfc | 4 +- system/reports/DotReporter.cfc | 2 +- system/reports/IReporter.cfc | 4 +- system/reports/JSONReporter.cfc | 4 +- system/reports/JUnitReporter.cfc | 36 +-- system/reports/MinReporter.cfc | 4 +- system/reports/MinTextReporter.cfc | 4 +- system/reports/RawReporter.cfc | 3 +- system/reports/SimpleReporter.cfc | 5 +- system/reports/TapReporter.cfc | 4 +- system/reports/TextReporter.cfc | 4 +- system/reports/XMLReporter.cfc | 9 +- system/runners/BDDRunner.cfc | 35 ++- system/runners/BaseRunner.cfc | 12 +- system/runners/IRunner.cfc | 5 +- system/runners/UnitRunner.cfc | 40 ++- system/util/MixerUtil.cfc | 14 +- system/util/Util.cfc | 22 +- tests/specs/AssertionsTest.cfc | 5 +- tests/specs/Assertionscf9Test.cfc | 60 ++++- tests/specs/BDDTest.cfc | 7 +- tests/specs/DebugTests.cfc | 5 +- tests/specs/EdgeCases.cfc | 10 +- tests/specs/MXUnitCompatTest.cfc | 48 +++- tests/specs/TestExecutionSequence.cfc | 82 +++--- tests/specs/mockbox/MockBoxTest.cfc | 148 +++++++--- 50 files changed, 1003 insertions(+), 382 deletions(-) diff --git a/system/Assertion.cfc b/system/Assertion.cfc index 55b86f28..7f2f384d 100644 --- a/system/Assertion.cfc +++ b/system/Assertion.cfc @@ -26,8 +26,14 @@ component { * @expression The expression to test * @message The message to send in the failure */ - function assert( required boolean expression, message = "" ){ - return isTrue( arguments.expression, arguments.message ); + function assert( + required boolean expression, + message = "" + ){ + return isTrue( + arguments.expression, + arguments.message + ); } /** @@ -35,7 +41,10 @@ component { * @actual The actual data to test * @message The message to send in the failure */ - function isTrue( required boolean actual, message = "" ){ + function isTrue( + required boolean actual, + message = "" + ){ arguments.message = ( len( arguments.message ) ? arguments.message : "Expected [#arguments.actual#] to be true" ); if ( NOT arguments.actual ) { fail( arguments.message ); @@ -48,7 +57,10 @@ component { * @actual The actual data to test * @message The message to send in the failure */ - function isFalse( required boolean actual, message = "" ){ + function isFalse( + required boolean actual, + message = "" + ){ arguments.message = ( len( arguments.message ) ? arguments.message : "Expected [#arguments.actual#] to be false" ); if ( arguments.actual ) { fail( arguments.message ); @@ -688,7 +700,12 @@ component { return this; } } else if ( isDate( arguments.actual ) ) { - if ( !listFindNoCase( "yyyy,q,m,ww,w,y,d,h,n,s,l", arguments.datePart ) ) { + if ( + !listFindNoCase( + "yyyy,q,m,ww,w,y,d,h,n,s,l", + arguments.datePart + ) + ) { fail( "The passed in datepart [#arguments.datepart#] is not valid." ); } @@ -1021,8 +1038,14 @@ component { } // Get both column lists and sort them the same - var actualColumnList = listSort( arguments.actual.columnList, "textNoCase" ); - var expectedColumnList = listSort( arguments.expected.columnList, "textNoCase" ); + var actualColumnList = listSort( + arguments.actual.columnList, + "textNoCase" + ); + var expectedColumnList = listSort( + arguments.expected.columnList, + "textNoCase" + ); // Check column lists if ( actualColumnList != expectedColumnList ) { @@ -1081,7 +1104,12 @@ component { return false; } // And make sure they match - if ( !equalize( arguments.actual[ i ], arguments.expected[ i ] ) ) { + if ( + !equalize( + arguments.actual[ i ], + arguments.expected[ i ] + ) + ) { return false; } continue; @@ -1100,9 +1128,15 @@ component { // Structs / Object if ( isStruct( arguments.actual ) && isStruct( arguments.expected ) ) { - var actualKeys = listSort( structKeyList( arguments.actual ), "textNoCase" ); - var expectedKeys = listSort( structKeyList( arguments.expected ), "textNoCase" ); - var key = ""; + var actualKeys = listSort( + structKeyList( arguments.actual ), + "textNoCase" + ); + var expectedKeys = listSort( + structKeyList( arguments.expected ), + "textNoCase" + ); + var key = ""; // Confirm both structs have the same keys if ( actualKeys neq expectedKeys ) { @@ -1120,7 +1154,12 @@ component { return false; } // And make sure they match when actual values exist - if ( !equalize( arguments.actual[ key ], arguments.expected[ key ] ) ) { + if ( + !equalize( + arguments.actual[ key ], + arguments.expected[ key ] + ) + ) { return false; } } @@ -1150,7 +1189,10 @@ component { if ( listFirst( server.coldfusion.productversion ) lt 10 ) { if ( isCustomFunction( arguments.target ) ) { - throw( type = "InvalidType", message = "You sent an invalid type for length checking (function)" ); + throw( + type = "InvalidType", + message = "You sent an invalid type for length checking (function)" + ); } } else { if ( isCustomFunction( arguments.target ) or isClosure( arguments.target ) ) { diff --git a/system/BaseSpec.cfc b/system/BaseSpec.cfc index e842c5ca..114b50ce 100644 --- a/system/BaseSpec.cfc +++ b/system/BaseSpec.cfc @@ -39,13 +39,13 @@ component { this.$focusedTargets = { "suites" : [], "specs" : [] }; // Setup Request Utilities - if( !request.keyExists( "testbox" ) ){ + if ( !request.keyExists( "testbox" ) ) { request.testbox = { - "console" : variables.console, - "debug" : variables.debug, + "console" : variables.console, + "debug" : variables.debug, "clearDebugBuffer" : variables.clearDebugBuffer, - "print" : variables.print, - "println" : variables.println + "print" : variables.print, + "println" : variables.println }; request.$testID = this.$testID; } @@ -208,7 +208,10 @@ component { // Are we in a nested describe() block if ( len( this.$suiteContext ) and this.$suiteContext neq arguments.title ) { // Append this suite to the nested suite. - arrayAppend( this.$suitesReverseLookup[ this.$suiteContext ].suites, suite ); + arrayAppend( + this.$suitesReverseLookup[ this.$suiteContext ].suites, + suite + ); this.$suitesReverseLookup[ arguments.title ] = suite; // Setup parent reference @@ -247,7 +250,10 @@ component { // Are we focused? if ( arguments.focused ) { - arrayAppend( this.$focusedTargets.suites, suite.slug & "/" & suite.name ); + arrayAppend( + this.$focusedTargets.suites, + suite.slug & "/" & suite.name + ); } // Restart spec index @@ -272,7 +278,10 @@ component { boolean asyncAll = false, any skip = false ){ - return describe( argumentCollection = arguments, title = "Story: " & arguments.story ); + return describe( + argumentCollection = arguments, + title = "Story: " & arguments.story + ); } /** @@ -291,7 +300,10 @@ component { boolean asyncAll = false, any skip = false ){ - return fdescribe( argumentCollection = arguments, title = "Story: " & arguments.story ); + return fdescribe( + argumentCollection = arguments, + title = "Story: " & arguments.story + ); } /** @@ -310,7 +322,10 @@ component { boolean asyncAll = false, any skip = false ){ - return describe( argumentCollection = arguments, title = "Feature: " & arguments.feature ); + return describe( + argumentCollection = arguments, + title = "Feature: " & arguments.feature + ); } /** @@ -329,7 +344,10 @@ component { boolean asyncAll = false, any skip = false ){ - return fdescribe( argumentCollection = arguments, title = "Feature: " & arguments.feature ); + return fdescribe( + argumentCollection = arguments, + title = "Feature: " & arguments.feature + ); } /** @@ -348,7 +366,10 @@ component { boolean asyncAll = false, any skip = false ){ - return describe( argumentCollection = arguments, title = "Given " & arguments.given ); + return describe( + argumentCollection = arguments, + title = "Given " & arguments.given + ); } /** @@ -367,7 +388,10 @@ component { boolean asyncAll = false, any skip = false ){ - return fdescribe( argumentCollection = arguments, title = "Given " & arguments.given ); + return fdescribe( + argumentCollection = arguments, + title = "Given " & arguments.given + ); } /** @@ -386,7 +410,10 @@ component { boolean asyncAll = false, any skip = false ){ - return describe( argumentCollection = arguments, title = "Scenario: " & arguments.scenario ); + return describe( + argumentCollection = arguments, + title = "Scenario: " & arguments.scenario + ); } /** @@ -405,7 +432,10 @@ component { boolean asyncAll = false, any skip = false ){ - return fdescribe( argumentCollection = arguments, title = "Scenario: " & arguments.scenario ); + return fdescribe( + argumentCollection = arguments, + title = "Scenario: " & arguments.scenario + ); } /** @@ -424,7 +454,10 @@ component { boolean asyncAll = false, any skip = false ){ - return describe( argumentCollection = arguments, title = "When " & arguments.when ); + return describe( + argumentCollection = arguments, + title = "When " & arguments.when + ); } /** @@ -443,7 +476,10 @@ component { boolean asyncAll = false, any skip = false ){ - return fdescribe( argumentCollection = arguments, title = "When " & arguments.when ); + return fdescribe( + argumentCollection = arguments, + title = "When " & arguments.when + ); } /** @@ -527,12 +563,18 @@ component { } // Attach this spec to the incoming context array of specs - arrayAppend( this.$suitesReverseLookup[ this.$suiteContext ].specs, spec ); + arrayAppend( + this.$suitesReverseLookup[ this.$suiteContext ].specs, + spec + ); // Are we focused? if ( arguments.focused ) { var thisSuite = this.$suitesReverseLookup[ this.$suiteContext ]; - arrayAppend( this.$focusedTargets.specs, thisSuite.slug & "/" & thisSuite.name & "/" & spec.name ); + arrayAppend( + this.$focusedTargets.specs, + thisSuite.slug & "/" & thisSuite.name & "/" & spec.name + ); } return this; @@ -554,7 +596,10 @@ component { any skip = false, struct data = {} ){ - return it( argumentCollection = arguments, title = "Then " & arguments.then ); + return it( + argumentCollection = arguments, + title = "Then " & arguments.then + ); } /** @@ -573,7 +618,10 @@ component { any skip = false, struct data = {} ){ - return fit( argumentCollection = arguments, title = "Then " & arguments.then ); + return fit( + argumentCollection = arguments, + title = "Then " & arguments.then + ); } /** @@ -744,7 +792,10 @@ component { // Do we have any custom matchers to add to this expectation? if ( !structIsEmpty( this.$customMatchers ) ) { for ( var thisMatcher in this.$customMatchers ) { - oExpectation.registerMatcher( thisMatcher, this.$customMatchers[ thisMatcher ] ); + oExpectation.registerMatcher( + thisMatcher, + this.$customMatchers[ thisMatcher ] + ); } } @@ -865,7 +916,12 @@ component { options = { coverage : { enabled : false } } ); // Produce report - writeOutput( runner.run( testSuites = arguments.testSuites, testSpecs = arguments.testSpecs ) ); + writeOutput( + runner.run( + testSuites = arguments.testSuites, + testSpecs = arguments.testSpecs + ) + ); } /** @@ -925,8 +981,14 @@ component { if ( !arguments.spec.skip && // Not skipping isSpecFocused( arguments.suite.slug & "/" & arguments.suite.name & "/" & arguments.spec.name ) && // Is the spec focused - arguments.runner.canRunLabel( consolidatedLabels, arguments.testResults ) && // In label or no labels - arguments.runner.canRunSpec( arguments.spec.name, arguments.testResults ) // In test results + arguments.runner.canRunLabel( + consolidatedLabels, + arguments.testResults + ) && // In label or no labels + arguments.runner.canRunSpec( + arguments.spec.name, + arguments.testResults + ) // In test results ) { // setup the current executing spec for debug purposes this.$currentExecutingSpec = arguments.suite.slug & "/" & arguments.suite.name & "/" & arguments.spec.name; @@ -1008,15 +1070,21 @@ component { } // Incorporate annotated methods - arrayEach( this.$utility.getAnnotatedMethods( annotation = "beforeEach", metadata = getMetadata( this ) ), function( item ){ - arrayAppend( - reverseTree, - { - beforeEach : this[ arguments.item.name ], - beforeEachData : {} - } - ); - } ); + arrayEach( + this.$utility.getAnnotatedMethods( + annotation = "beforeEach", + metadata = getMetadata( this ) + ), + function( item ){ + arrayAppend( + reverseTree, + { + beforeEach : this[ arguments.item.name ], + beforeEachData : {} + } + ); + } + ); // sort tree backwards arraySort( reverseTree, function( a, b ){ @@ -1025,11 +1093,17 @@ component { // Execute it arrayEach( reverseTree, function( item ){ - item.beforeEach( currentSpec = spec.name, data = item.beforeEachData ); + item.beforeEach( + currentSpec = spec.name, + data = item.beforeEachData + ); } ); // execute beforeEach() - arguments.suite.beforeEach( currentSpec = arguments.spec.name, data = arguments.suite.beforeEachData ); + arguments.suite.beforeEach( + currentSpec = arguments.spec.name, + data = arguments.suite.beforeEachData + ); return this; } @@ -1070,19 +1144,25 @@ component { } // Discover annotated methods and add to reverseTree - arrayEach( this.$utility.getAnnotatedMethods( annotation = "aroundEach", metadata = getMetadata( this ) ), function( item ){ - arrayAppend( - reverseTree, - { - name : arguments.item.name, - body : this[ arguments.item.name ], - data : {}, - labels : {}, - order : 0, - skip : false - } - ); - } ); + arrayEach( + this.$utility.getAnnotatedMethods( + annotation = "aroundEach", + metadata = getMetadata( this ) + ), + function( item ){ + arrayAppend( + reverseTree, + { + name : arguments.item.name, + body : this[ arguments.item.name ], + data : {}, + labels : {}, + order : 0, + skip : false + } + ); + } + ); // Sort the closures from the oldest parent down to the current spec arraySort( reverseTree, function( a, b ){ @@ -1164,22 +1244,34 @@ component { */ BaseSpec function runAfterEachClosures( required suite, required spec ){ // execute nearest afterEach() - arguments.suite.afterEach( currentSpec = arguments.spec.name, data = arguments.suite.afterEachData ); + arguments.suite.afterEach( + currentSpec = arguments.spec.name, + data = arguments.suite.afterEachData + ); // do we have nested suites? If so, traverse and execute life-cycle methods up the tree backwards var parentSuite = arguments.suite.parentRef; while ( !isSimpleValue( parentSuite ) ) { - parentSuite.afterEach( currentSpec = arguments.spec.name, data = parentSuite.afterEachData ); + parentSuite.afterEach( + currentSpec = arguments.spec.name, + data = parentSuite.afterEachData + ); parentSuite = parentSuite.parentRef; } - arrayEach( this.$utility.getAnnotatedMethods( annotation = "afterEach", metadata = getMetadata( this ) ), function( item ){ - invoke( - this, - item.name, - { currentSpec : spec.name, data : {} } - ); - } ); + arrayEach( + this.$utility.getAnnotatedMethods( + annotation = "afterEach", + metadata = getMetadata( this ) + ), + function( item ){ + invoke( + this, + item.name, + { currentSpec : spec.name, data : {} } + ); + } + ); return this; } @@ -1207,8 +1299,14 @@ component { // Verify we can execute if ( !arguments.spec.skip && - arguments.runner.canRunLabel( arguments.spec.labels, arguments.testResults ) && - arguments.runner.canRunSpec( arguments.spec.name, arguments.testResults ) + arguments.runner.canRunLabel( + arguments.spec.labels, + arguments.testResults + ) && + arguments.runner.canRunSpec( + arguments.spec.name, + arguments.testResults + ) ) { // Reset expected exceptions: Only works on synchronous testing. this.$expectedException = {}; @@ -1225,7 +1323,12 @@ component { invoke( this, arguments.spec.name ); // Where we expecting an exception and it did not throw? - if ( hasExpectedException( arguments.spec.name, arguments.runner ) ) { + if ( + hasExpectedException( + arguments.spec.name, + arguments.runner + ) + ) { $assert.fail( "Method did not throw expected exception: [#this.$expectedException.toString()#]" ); @@ -1233,7 +1336,12 @@ component { // else all good. } catch ( Any e ) { // do we have expected exception? else rethrow it - if ( !hasExpectedException( arguments.spec.name, arguments.runner ) ) { + if ( + !hasExpectedException( + arguments.spec.name, + arguments.runner + ) + ) { rethrow; } // if not the expected exception, then fail it @@ -1478,7 +1586,7 @@ component { string className, any object, boolean clearMethods = false - boolean callLogging =true + boolean callLogging =true ){ return this.$mockBox.createMock( argumentCollection = arguments ); } @@ -1488,7 +1596,10 @@ component { * @object The object to mock, already instantiated * @callLogging Add method call logging for all mocked methods. Defaults to true */ - function prepareMock( any object, boolean callLogging = true ){ + function prepareMock( + any object, + boolean callLogging = true + ){ return this.$mockBox.prepareMock( argumentCollection = arguments ); } @@ -1556,14 +1667,24 @@ component { else if ( len( this.$expectedException.type ) && arguments.exception.type eq this.$expectedException.type && - arrayLen( reMatchNoCase( this.$expectedException.regex, arguments.exception.message ) ) + arrayLen( + reMatchNoCase( + this.$expectedException.regex, + arguments.exception.message + ) + ) ) { results = true; } // Message regex then only else if ( this.$expectedException.regex neq ".*" && - arrayLen( reMatchNoCase( this.$expectedException.regex, arguments.exception.message ) ) + arrayLen( + reMatchNoCase( + this.$expectedException.regex, + arguments.exception.message + ) + ) ) { results = true; } diff --git a/system/CollectionExpectation.cfc b/system/CollectionExpectation.cfc index 3ab671f8..4f96a8dc 100644 --- a/system/CollectionExpectation.cfc +++ b/system/CollectionExpectation.cfc @@ -33,7 +33,10 @@ component accessors="true" { return this; } - function onMissingMethod( string missingMethodName, any missingMethodArguments ){ + function onMissingMethod( + string missingMethodName, + any missingMethodArguments + ){ if ( isArray( variables.actual ) ) { for ( var e in variables.actual ) { // Using evaluate since invoke looses track of positional argument collections diff --git a/system/Expectation.cfc b/system/Expectation.cfc index 44f69d22..2a4f965b 100644 --- a/system/Expectation.cfc +++ b/system/Expectation.cfc @@ -68,13 +68,19 @@ component accessors="true" { /** * Process dynamic expectations like any matcher starting with the word "not" is negated */ - function onMissingMethod( required missingMethodName, required missingMethodArguments ){ + function onMissingMethod( + required missingMethodName, + required missingMethodArguments + ){ // detect negation if ( left( arguments.missingMethodName, 3 ) eq "not" ) { // remove NOT - arguments.missingMethodName = right( arguments.missingMethodName, len( arguments.missingMethodName ) - 3 ); + arguments.missingMethodName = right( + arguments.missingMethodName, + len( arguments.missingMethodName ) - 3 + ); // set isNot pivot on this matcher - this.isNot = true; + this.isNot = true; // execute the dynamic method var results = invoke( @@ -97,13 +103,22 @@ component accessors="true" { ) ) { // remove the toBe to get the type. - var type = right( arguments.missingMethodName, len( arguments.missingMethodName ) - 4 ); + var type = right( + arguments.missingMethodName, + len( arguments.missingMethodName ) - 4 + ); // detect incoming message var message = ( - structKeyExists( arguments.missingMethodArguments, "message" ) ? arguments.missingMethodArguments.message : "" + structKeyExists( + arguments.missingMethodArguments, + "message" + ) ? arguments.missingMethodArguments.message : "" ); message = ( - structKeyExists( arguments.missingMethodArguments, "1" ) ? arguments.missingMethodArguments[ 1 ] : message + structKeyExists( + arguments.missingMethodArguments, + "1" + ) ? arguments.missingMethodArguments[ 1 ] : message ); // execute the method return toBeTypeOf( type = type, message = message ); @@ -183,7 +198,10 @@ component accessors="true" { * @expected The expected data * @message The message to send in the failure */ - function toBeWithCase( required string expected, message = "" ){ + function toBeWithCase( + required string expected, + message = "" + ){ arguments.actual = this.actual; if ( this.isNot ) { variables.assert.isNotEqual( argumentCollection = arguments ); @@ -222,7 +240,10 @@ component accessors="true" { * @typeName The typename to check * @message The message to send in the failure */ - function toBeInstanceOf( required string typeName, message = "" ){ + function toBeInstanceOf( + required string typeName, + message = "" + ){ arguments.actual = this.actual; if ( this.isNot ) { variables.assert.notInstanceOf( argumentCollection = arguments ); diff --git a/system/MockBox.cfc b/system/MockBox.cfc index 1a0fd1c8..c21227ed 100644 --- a/system/MockBox.cfc +++ b/system/MockBox.cfc @@ -3,8 +3,8 @@ Copyright Since 2005 TestBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com ******************************************************************************** -Author : Luis Majano -Date : April 20, 2009 +Author : Luis Majano +Date : April 20, 2009 Description : The Official ColdBox Mocking Factory -----------------------------------------------------------------------> @@ -38,10 +38,10 @@ The Official ColdBox Mocking Factory instance.generationPath = instance.generationPath & "/"; } - instance.mockGenerator = createObject( "component", "testbox.system.mockutils.MockGenerator" ).init( - this, - false - ); + instance.mockGenerator = createObject( + "component", + "testbox.system.mockutils.MockGenerator" + ).init( this, false ); return this; @@ -232,7 +232,10 @@ The Official ColdBox Mocking Factory // No implements or inheritance if ( NOT len( trim( arguments.implements ) ) AND NOT len( trim( arguments.extends ) ) ) { - return createMock( className = "testbox.system.mockutils.Stub", callLogging = arguments.callLogging ); + return createMock( + className = "testbox.system.mockutils.Stub", + callLogging = arguments.callLogging + ); } // Generate the CFC + Create it + Remove it return prepareMock( instance.mockGenerator.generateCFC( argumentCollection = arguments ) ); @@ -319,7 +322,12 @@ The Official ColdBox Mocking Factory // If method name used? Count only this method signatures if ( len( arguments.methodName ) ) { - if ( structKeyExists( this._mockMethodCallCounters, arguments.methodName ) ) { + if ( + structKeyExists( + this._mockMethodCallCounters, + arguments.methodName + ) + ) { return this._mockMethodCallCounters[ arguments.methodName ]; } return -1; @@ -943,6 +951,9 @@ The Official ColdBox Mocking Factory returntype="testbox.system.util.Util" hint ="Create and return a util object" > - + diff --git a/system/TestBox.cfc b/system/TestBox.cfc index 462ae8a8..c470cecf 100644 --- a/system/TestBox.cfc +++ b/system/TestBox.cfc @@ -82,7 +82,10 @@ component accessors="true" { * Constructor * @directory A directory to test which can be a simple mapping path or a struct with the following options: [ mapping = the path to the directory using dot notation (myapp.testing.specs), recurse = boolean, filter = closure that receives the path of the CFC found, it must return true to process or false to continue process ] */ - any function addDirectory( required any directory, boolean recurse = true ){ + any function addDirectory( + required any directory, + boolean recurse = true + ){ // inflate directory? if ( isSimpleValue( arguments.directory ) ) { arguments.directory = { @@ -103,7 +106,10 @@ component accessors="true" { * Constructor * @directories A set of directories to test which can be a list of simple mapping paths or an array of structs with the following options: [ mapping = the path to the directory using dot notation (myapp.testing.specs), recurse = boolean, filter = closure that receives the path of the CFC found, it must return true to process or false to continue process ] */ - any function addDirectories( required any directories, boolean recurse = true ){ + any function addDirectories( + required any directories, + boolean recurse = true + ){ if ( isSimpleValue( arguments.directories ) ) { arguments.directories = listToArray( arguments.directories ); } @@ -395,14 +401,38 @@ component accessors="true" { try { var response = getPageContext().getResponse(); - response.addHeader( "x-testbox-totalDuration", javacast( "string", results.getTotalDuration() ) ); - response.addHeader( "x-testbox-totalBundles", javacast( "string", results.getTotalBundles() ) ); - response.addHeader( "x-testbox-totalSuites", javacast( "string", results.getTotalSuites() ) ); - response.addHeader( "x-testbox-totalSpecs", javacast( "string", results.getTotalSpecs() ) ); - response.addHeader( "x-testbox-totalPass", javacast( "string", results.getTotalPass() ) ); - response.addHeader( "x-testbox-totalFail", javacast( "string", results.getTotalFail() ) ); - response.addHeader( "x-testbox-totalError", javacast( "string", results.getTotalError() ) ); - response.addHeader( "x-testbox-totalSkipped", javacast( "string", results.getTotalSkipped() ) ); + response.addHeader( + "x-testbox-totalDuration", + javacast( "string", results.getTotalDuration() ) + ); + response.addHeader( + "x-testbox-totalBundles", + javacast( "string", results.getTotalBundles() ) + ); + response.addHeader( + "x-testbox-totalSuites", + javacast( "string", results.getTotalSuites() ) + ); + response.addHeader( + "x-testbox-totalSpecs", + javacast( "string", results.getTotalSpecs() ) + ); + response.addHeader( + "x-testbox-totalPass", + javacast( "string", results.getTotalPass() ) + ); + response.addHeader( + "x-testbox-totalFail", + javacast( "string", results.getTotalFail() ) + ); + response.addHeader( + "x-testbox-totalError", + javacast( "string", results.getTotalError() ) + ); + response.addHeader( + "x-testbox-totalSkipped", + javacast( "string", results.getTotalSkipped() ) + ); } catch ( Any e ) { writeLog( type = "error", @@ -533,14 +563,20 @@ component accessors="true" { // Discover type? if ( structKeyExists( target, "run" ) ) { // Run via BDD Style - new testbox.system.runners.BDDRunner( options = variables.options, testbox = this ).run( + new testbox.system.runners.BDDRunner( + options = variables.options, + testbox = this + ).run( target, arguments.testResults, arguments.callbacks ); } else { // Run via xUnit Style - new testbox.system.runners.UnitRunner( options = variables.options, testbox = this ).run( + new testbox.system.runners.UnitRunner( + options = variables.options, + testbox = this + ).run( target, arguments.testResults, arguments.callbacks @@ -570,7 +606,10 @@ component accessors="true" { * @bundlePath The path to the Bundle CFC */ private any function getBundle( required bundlePath ){ - var bundle = createObject( "component", "#arguments.bundlePath#" ); + var bundle = createObject( + "component", + "#arguments.bundlePath#" + ); var familyPath = "testbox.system.BaseSpec"; // check if base spec assigned diff --git a/system/TestResult.cfc b/system/TestResult.cfc index eb637278..0e3cc5b1 100644 --- a/system/TestResult.cfc +++ b/system/TestResult.cfc @@ -93,7 +93,7 @@ component accessors="true" { variables.coverageData = {}; // CFML Engine + Version - variables.CFMLEngine = server.coldfusion.productName; + variables.CFMLEngine = server.coldfusion.productName; variables.CFMLEngineVersion = ( structKeyExists( server, "lucee" ) ? server.lucee.version : server.coldfusion.productVersion ); @@ -107,7 +107,10 @@ component accessors="true" { TestResult function end(){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { if ( isComplete() ) { - throw( type = "InvalidState", message = "Testing is already complete." ); + throw( + type = "InvalidState", + message = "Testing is already complete." + ); } variables.endTime = getTickCount(); variables.totalDuration = variables.endTime - variables.startTime; @@ -148,7 +151,10 @@ component accessors="true" { * Increment a global stat * @type The type of stat to increment: fail,pass,error or skipped */ - TestResult function incrementStat( required type = "pass", numeric count = 1 ){ + TestResult function incrementStat( + required type = "pass", + numeric count = 1 + ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { switch ( arguments.type ) { case "fail": { @@ -175,7 +181,10 @@ component accessors="true" { /** * Start a new bundle stats and return its reference */ - struct function startBundleStats( required string bundlePath, required string name ){ + struct function startBundleStats( + required string bundlePath, + required string name + ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { // setup stats data for incoming bundle var stats = { @@ -305,10 +314,16 @@ component accessors="true" { // link parent stats.parentID = arguments.parentStats.id; // store it in the nested suite - arrayAppend( arguments.parentStats.suiteStats, stats ); + arrayAppend( + arguments.parentStats.suiteStats, + stats + ); } else { // store it in the bundle stats - arrayAppend( arguments.bundleStats.suiteStats, stats ); + arrayAppend( + arguments.bundleStats.suiteStats, + stats + ); } // store in the reverse lookup for faster access @@ -334,7 +349,10 @@ component accessors="true" { * @name The name of the suite * @suiteStats The suite stats reference this belongs to. */ - struct function startSpecStats( required string name, required struct suiteStats ){ + struct function startSpecStats( + required string name, + required struct suiteStats + ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { // spec stats var stats = { @@ -365,7 +383,10 @@ component accessors="true" { }; // append to the parent stats - arrayAppend( arguments.suiteStats.specStats, stats ); + arrayAppend( + arguments.suiteStats.specStats, + stats + ); } // end lock @@ -377,7 +398,10 @@ component accessors="true" { * @type The type of stat to store: skipped,fail,error,pass * @specStats The spec stats to increment */ - function incrementSpecStat( required string type, required struct stats ){ + function incrementSpecStat( + required string type, + required struct stats + ){ lock name="tb-results-#variables.resultsID#" type="exclusive" timeout="10" { // increment suite stat variables.suiteReverseLookup[ arguments.stats.suiteID ][ "total#arguments.type#" ]++; @@ -416,23 +440,19 @@ component accessors="true" { "CFMLEngineVersion" ]; - var result = { - "coverage" : {} - }; + var result = { "coverage" : {} }; // Do simple properties only for ( var thisProp in pList ) { if ( structKeyExists( variables, thisProp ) ) { - result[ thisProp ] = variables[ thisProp ]; // Do we need to strip out the buffer? if ( thisProp == "bundleStats" && !arguments.includeDebugBuffer ) { - for( var thisStat in result.bundleStats ){ + for ( var thisStat in result.bundleStats ) { thisStat.debugBuffer = []; } } - } else { result[ thisProp ] = ""; } @@ -460,4 +480,4 @@ component accessors="true" { return result; } -} \ No newline at end of file +} diff --git a/system/compat/framework/Results.cfc b/system/compat/framework/Results.cfc index ce36f9c4..91e90d6a 100644 --- a/system/compat/framework/Results.cfc +++ b/system/compat/framework/Results.cfc @@ -46,7 +46,10 @@ component { var tb = new testbox.system.TestBox( bundles = variables.bundles ); - return tb.run( testSpecs = variables.testSpecs, reporter = arguments.mode ); + return tb.run( + testSpecs = variables.testSpecs, + reporter = arguments.mode + ); } } diff --git a/system/compat/framework/TestCase.cfc b/system/compat/framework/TestCase.cfc index 31eb91da..6c4207f1 100644 --- a/system/compat/framework/TestCase.cfc +++ b/system/compat/framework/TestCase.cfc @@ -58,7 +58,10 @@ component extends="testbox.system.BaseSpec" { } } - var runner = new testbox.system.TestBox( bundles = "#getMetadata( this ).name#", reporter = arguments.output ); + var runner = new testbox.system.TestBox( + bundles = "#getMetadata( this ).name#", + reporter = arguments.output + ); // Produce report writeOutput( runner.run( testSpecs = arguments.testMethod ) ); @@ -113,8 +116,14 @@ component extends="testbox.system.BaseSpec" { * @expectedExceptionType.hint the type to expect * @expectedExceptionMessage.hint Optional exception message */ - function expectException( expectedExceptionType, expectedExceptionMessage = ".*" ){ - super.expectedException( arguments.expectedExceptionType, arguments.expectedExceptionMessage ); + function expectException( + expectedExceptionType, + expectedExceptionMessage = ".*" + ){ + super.expectedException( + arguments.expectedExceptionType, + arguments.expectedExceptionMessage + ); } /** @@ -152,27 +161,44 @@ component extends="testbox.system.BaseSpec" { getMockBox().prepareMock( arguments.receiver ); // inject it. - if ( structKeyExists( arguments.giver, arguments.functionName ) ) { + if ( + structKeyExists( + arguments.giver, + arguments.functionName + ) + ) { arguments.receiver.$property( propertyName = arguments.functionNameInReceiver, propertyScope = "this", - mock = arguments.giver.$getProperty( name = arguments.functionName, scope = "this" ) + mock = arguments.giver.$getProperty( + name = arguments.functionName, + scope = "this" + ) ); arguments.receiver.$property( propertyName = arguments.functionNameInReceiver, propertyScope = "variables", - mock = arguments.giver.$getProperty( name = arguments.functionName, scope = "this" ) + mock = arguments.giver.$getProperty( + name = arguments.functionName, + scope = "this" + ) ); } else { arguments.receiver.$property( propertyName = arguments.functionNameInReceiver, propertyScope = "this", - mock = arguments.giver.$getProperty( name = arguments.functionName, scope = "variables" ) + mock = arguments.giver.$getProperty( + name = arguments.functionName, + scope = "variables" + ) ); arguments.receiver.$property( propertyName = arguments.functionNameInReceiver, propertyScope = "variables", - mock = arguments.giver.$getProperty( name = arguments.functionName, scope = "variables" ) + mock = arguments.giver.$getProperty( + name = arguments.functionName, + scope = "variables" + ) ); } @@ -192,8 +218,14 @@ component extends="testbox.system.BaseSpec" { /** * Assert that the passed expression is true */ - function assert( required string condition, message = "" ){ - this.$assert.isTrue( arguments.condition, arguments.message ); + function assert( + required string condition, + message = "" + ){ + this.$assert.isTrue( + arguments.condition, + arguments.message + ); } /** @@ -244,8 +276,14 @@ component extends="testbox.system.BaseSpec" { /** * Assert something is false */ - function assertFalse( required string condition, message = "" ){ - this.$assert.isFalse( arguments.condition, arguments.message ); + function assertFalse( + required string condition, + message = "" + ){ + this.$assert.isFalse( + arguments.condition, + arguments.message + ); } /** @@ -330,8 +368,14 @@ component extends="testbox.system.BaseSpec" { /** * Assert something is true */ - function assertTrue( required string condition, message = "" ){ - this.$assert.isTrue( arguments.condition, arguments.message ); + function assertTrue( + required string condition, + message = "" + ){ + this.$assert.isTrue( + arguments.condition, + arguments.message + ); } /** @@ -401,14 +445,23 @@ component extends="testbox.system.BaseSpec" { * Assert something is defined or not */ function assertIsDefined( required o, message = "" ){ - this.$assert.isTrue( isDefined( evaluate( "arguments.o" ) ), arguments.message ); + this.$assert.isTrue( + isDefined( evaluate( "arguments.o" ) ), + arguments.message + ); } /** * Assert something is an XMLDoc */ - function assertIsXMLDoc( required xml, message = "Passed in xml is not a valid XML Object" ){ - this.$assert.isTrue( isXMLDoc( arguments.xml ), arguments.message ); + function assertIsXMLDoc( + required xml, + message = "Passed in xml is not a valid XML Object" + ){ + this.$assert.isTrue( + isXMLDoc( arguments.xml ), + arguments.message + ); } /** diff --git a/system/compat/framework/TestSuite.cfc b/system/compat/framework/TestSuite.cfc index 8ea3c1e8..72479d42 100644 --- a/system/compat/framework/TestSuite.cfc +++ b/system/compat/framework/TestSuite.cfc @@ -17,20 +17,35 @@ component accessors="true" { return this; } - remote function addTest( required componentName, required method ){ - arrayAppend( variables.bundles, arguments.componentName ); + remote function addTest( + required componentName, + required method + ){ + arrayAppend( + variables.bundles, + arguments.componentName + ); variables.testSpecs.addAll( listToArray( arguments.method ) ); return this; } - remote function add( required componentName, required methods ){ - arrayAppend( variables.bundles, arguments.componentName ); + remote function add( + required componentName, + required methods + ){ + arrayAppend( + variables.bundles, + arguments.componentName + ); variables.testSpecs.addAll( listToArray( arguments.methods ) ); return this; } remote function addAll( required componentName ){ - arrayAppend( variables.bundles, arguments.componentName ); + arrayAppend( + variables.bundles, + arguments.componentName + ); return this; } @@ -38,7 +53,10 @@ component accessors="true" { if ( len( arguments.testMethod ) ) { variables.testSpecs.addAll( listToArray( arguments.testMethod ) ); } - return new Results( variables.bundles, variables.testSpecs ); + return new Results( + variables.bundles, + variables.testSpecs + ); } /** @@ -52,7 +70,10 @@ component accessors="true" { boolean debug = false, output = "simple" ) output=true{ - var runner = new testbox.system.TestBox( bundles = "#getMetadata( this ).name#", reporter = arguments.output ); + var runner = new testbox.system.TestBox( + bundles = "#getMetadata( this ).name#", + reporter = arguments.output + ); // Produce report writeOutput( runner.run( testSpecs = arguments.testMethod ) ); diff --git a/system/compat/runner/DirectoryTestSuite.cfc b/system/compat/runner/DirectoryTestSuite.cfc index 11fcbce1..7074617d 100644 --- a/system/compat/runner/DirectoryTestSuite.cfc +++ b/system/compat/runner/DirectoryTestSuite.cfc @@ -38,10 +38,13 @@ > - var explorer = createObject( "component", "CFIDE.componentutils.cfcexplorer" ); - var target = explorer.normalizePath( arguments.path ); - var cfcs = explorer.getcfcs( true ); // true == refresh cache - var package = ""; + var explorer = createObject( + "component", + "CFIDE.componentutils.cfcexplorer" + ); + var target = explorer.normalizePath( arguments.path ); + var cfcs = explorer.getcfcs( true ); // true == refresh cache + var package = ""; for ( var i = 1; i lte arrayLen( cfcs ); i++ ) { var cfc = cfcs[ i ]; diff --git a/system/compat/runner/Results.cfc b/system/compat/runner/Results.cfc index 97eec8a9..21a8b7cd 100644 --- a/system/compat/runner/Results.cfc +++ b/system/compat/runner/Results.cfc @@ -61,7 +61,10 @@ component { private function filterExcludes( required path ){ var excludes = getOptions().excludes; - var cfcName = listFirst( getFileFromPath( arguments.path ), "." ); + var cfcName = listFirst( + getFileFromPath( arguments.path ), + "." + ); return ( listFindNoCase( excludes, cfcName ) ? false : true ); } diff --git a/system/coverage/CoverageService.cfc b/system/coverage/CoverageService.cfc index e5432828..3fbc5baa 100644 --- a/system/coverage/CoverageService.cfc +++ b/system/coverage/CoverageService.cfc @@ -89,7 +89,10 @@ component accessors="true" { var qryCoverageData = generateCoverageData( getCoverageOptions() ); // SonarQube Integration - var sonarQubeResults = processSonarQube( qryCoverageData, getCoverageOptions() ); + var sonarQubeResults = processSonarQube( + qryCoverageData, + getCoverageOptions() + ); // Generate Stats var stats = processStats( qryCoverageData ); @@ -116,7 +119,10 @@ component accessors="true" { /** * Render HTML representation of statistics */ - function renderStats( required struct coverageData, boolean fullPage = true ){ + function renderStats( + required struct coverageData, + boolean fullPage = true + ){ var stats = coverageData.stats; var pathToCapture = getCoverageOptions().pathToCapture; @@ -240,7 +246,10 @@ component accessors="true" { /** * Write out SonarQube generic coverage XML file */ - private function processSonarQube( required query qryCoverageData, required struct opts ){ + private function processSonarQube( + required query qryCoverageData, + required struct opts + ){ if ( len( opts.sonarQube.XMLOutputPath ) ) { // Create XML generator var sonarQube = new sonarqube.SonarQube(); @@ -248,7 +257,10 @@ component accessors="true" { sonarQube.setFormatXML( true ); // Generate XML (writes file and returns string - sonarQube.generateXML( qryCoverageData, opts.sonarQube.XMLOutputPath ); + sonarQube.generateXML( + qryCoverageData, + opts.sonarQube.XMLOutputPath + ); return opts.sonarQube.XMLOutputPath; } return ""; diff --git a/system/coverage/browser/CodeBrowser.cfc b/system/coverage/browser/CodeBrowser.cfc index 7f44d044..bdfe3753 100644 --- a/system/coverage/browser/CodeBrowser.cfc +++ b/system/coverage/browser/CodeBrowser.cfc @@ -56,7 +56,10 @@ component accessors=true { savecontent variable="local.index" { include "templates/index.cfm"; } - fileWrite( browserOutputDir & "/index.html", local.index ); + fileWrite( + browserOutputDir & "/index.html", + local.index + ); // Create directory skeletons var dataStream = variables.streamBuilder diff --git a/system/coverage/data/CoverageGenerator.cfc b/system/coverage/data/CoverageGenerator.cfc index 81b6dd7e..8b1b7767 100644 --- a/system/coverage/data/CoverageGenerator.cfc +++ b/system/coverage/data/CoverageGenerator.cfc @@ -26,9 +26,12 @@ component accessors=true { */ boolean function configure(){ try { - variables.fragentClass = createObject( "java", "com.intergral.fusionreactor.agent.Agent" ); + variables.fragentClass = createObject( + "java", + "com.intergral.fusionreactor.agent.Agent" + ); // Do a quick test to ensure the line performance instrumentation is loaded. This will return null for non-supported versions of FR - var instrumentation = fragentClass.getAgentInstrumentation().get( "cflpi" ); + var instrumentation = fragentClass.getAgentInstrumentation().get( "cflpi" ); } catch ( Any e ) { return false; } @@ -41,7 +44,12 @@ component accessors=true { variables.pathPatternMatcher = new PathPatternMatcher(); // Detect server - if ( listFindNoCase( "Railo,Lucee", server.coldfusion.productname ) ) { + if ( + listFindNoCase( + "Railo,Lucee", + server.coldfusion.productname + ) + ) { variables.templateCompiler = new TemplateCompiler_Lucee(); } else { variables.templateCompiler = new TemplateCompiler_Adobe(); @@ -237,7 +245,12 @@ component accessors=true { } // Count as covered any cffunction or cfargument tag where the previous line ran. - if ( !covered && reFindNoCase( "^ @@ -119,7 +119,7 @@ A mock generator udfOut.append( " variables[ ""#safeMethodName#"" ] = variables[ ""@@tmpMethodName@@"" ]; - this[ ""#safeMethodName#"" ] = variables[ ""@@tmpMethodName@@"" ]; + this[ ""#safeMethodName#"" ] = variables[ ""@@tmpMethodName@@"" ]; // Clean up structDelete( variables, ""@@tmpMethodName@@"" ); structDelete( this, ""@@tmpMethodName@@"" ); @@ -166,14 +166,14 @@ A mock generator // Continue Method Generation udfOut.append( " - var results = this._mockResults; - var resultsKey = ""#arguments.method#""; - var resultsCounter = 0; + var results = this._mockResults; + var resultsKey = ""#arguments.method#""; + var resultsCounter = 0; var internalCounter = 0; - var resultsLen = 0; - var callbackLen = 0; - var argsHashKey = resultsKey & ""|"" & this.mockBox.normalizeArguments( arguments ); - var fCallBack = """"; + var resultsLen = 0; + var callbackLen = 0; + var argsHashKey = resultsKey & ""|"" & this.mockBox.normalizeArguments( arguments ); + var fCallBack = """"; // If Method & argument Hash Results, switch the results struct if( structKeyExists( this._mockArgResults, argsHashKey ) ) { @@ -184,7 +184,7 @@ A mock generator fCallBack = this._mockArgResults[ argsHashKey ].target; } else { // switch context and key - results = this._mockArgResults; + results = this._mockArgResults; resultsKey = argsHashKey; } } @@ -369,7 +369,10 @@ A mock generator // iterate over implementations for ( local.x = 1; local.x lte listLen( arguments.implements ); local.x++ ) { // generate interface methods - generateMethodsFromMD( udfOut, getComponentMetadata( listGetAt( arguments.implements, x ) ) ); + generateMethodsFromMD( + udfOut, + getComponentMetadata( listGetAt( arguments.implements, x ) ) + ); } // close it @@ -458,7 +461,10 @@ A mock generator // Check extends and recurse if ( structKeyExists( arguments.md, "extends" ) ) { for ( var thisKey in arguments.md.extends ) { - generateMethodsFromMD( udfOut, arguments.md.extends[ thisKey ] ); + generateMethodsFromMD( + udfOut, + arguments.md.extends[ thisKey ] + ); } } diff --git a/system/mockutils/Stub.cfc b/system/mockutils/Stub.cfc index 0d660418..ac7dfe4d 100644 --- a/system/mockutils/Stub.cfc +++ b/system/mockutils/Stub.cfc @@ -3,7 +3,7 @@ Copyright Since 2005 TestBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com ******************************************************************************** -Author : Luis Majano +Author : Luis Majano Description : A stub object ----------------------------------------------------------------------> diff --git a/system/reports/ANTJUnitReporter.cfc b/system/reports/ANTJUnitReporter.cfc index c39cef08..ef34257d 100644 --- a/system/reports/ANTJUnitReporter.cfc +++ b/system/reports/ANTJUnitReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, - boolean justReturn=false + struct options = {}, + boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { getPageContextResponse().setContentType( "application/xml" ); } @@ -58,15 +58,15 @@ component extends="BaseReporter" { // build test suite header buffer.append( "" ); @@ -103,21 +103,22 @@ component extends="BaseReporter" { var index = 1; // Do we have a global exception? - if( !isSimpleValue( arguments.bundleStats.globalException ) ){ + if ( !isSimpleValue( arguments.bundleStats.globalException ) ) { // build test case out.append( - " - "); + " + ); return; } @@ -164,8 +165,8 @@ component extends="BaseReporter" { // build test case out.append( "" ); diff --git a/system/reports/BaseReporter.cfc b/system/reports/BaseReporter.cfc index 6086032d..9cce9b3d 100644 --- a/system/reports/BaseReporter.cfc +++ b/system/reports/BaseReporter.cfc @@ -34,7 +34,10 @@ component { getPageContext().getOut().resetHTMLHead(); } catch ( any e ) { // don't care, that lucee version doesn't support it. - writeDump( var = "resetHTMLHead() not supported #e.message#", output = "console" ); + writeDump( + var = "resetHTMLHead() not supported #e.message#", + output = "console" + ); } } // reset cfheader from integration tests diff --git a/system/reports/CodexWikiReporter.cfc b/system/reports/CodexWikiReporter.cfc index 970335f3..b28f8e1e 100644 --- a/system/reports/CodexWikiReporter.cfc +++ b/system/reports/CodexWikiReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/text" ); } diff --git a/system/reports/ConsoleReporter.cfc b/system/reports/ConsoleReporter.cfc index 3611e30b..c401576c 100644 --- a/system/reports/ConsoleReporter.cfc +++ b/system/reports/ConsoleReporter.cfc @@ -31,10 +31,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/plain" ); } diff --git a/system/reports/DocReporter.cfc b/system/reports/DocReporter.cfc index 8f19349e..2decbc34 100644 --- a/system/reports/DocReporter.cfc +++ b/system/reports/DocReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/html" ); } diff --git a/system/reports/DotReporter.cfc b/system/reports/DotReporter.cfc index 9bad04f4..a3da26b8 100644 --- a/system/reports/DotReporter.cfc +++ b/system/reports/DotReporter.cfc @@ -30,7 +30,7 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ // bundle stats diff --git a/system/reports/IReporter.cfc b/system/reports/IReporter.cfc index 2bffc718..3be15a0f 100644 --- a/system/reports/IReporter.cfc +++ b/system/reports/IReporter.cfc @@ -24,8 +24,8 @@ interface { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, - boolean justReturn=false + struct options = {}, + boolean justReturn = false ); } diff --git a/system/reports/JSONReporter.cfc b/system/reports/JSONReporter.cfc index 387e2672..a58f5a4b 100644 --- a/system/reports/JSONReporter.cfc +++ b/system/reports/JSONReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { resetHTMLResponse(); getPageContextResponse().setContentType( "application/json" ); } diff --git a/system/reports/JUnitReporter.cfc b/system/reports/JUnitReporter.cfc index 085a2c06..30b8d7c6 100644 --- a/system/reports/JUnitReporter.cfc +++ b/system/reports/JUnitReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { resetHTMLResponse(); getPageContextResponse().setContentType( "application/xml" ); } @@ -46,13 +46,13 @@ component extends="BaseReporter" { // build top level test suites container buffer.append( "" ); @@ -90,15 +90,15 @@ component extends="BaseReporter" { // build test suite header out.append( "" ); @@ -148,10 +148,10 @@ component extends="BaseReporter" { // build test case out.append( "" ); diff --git a/system/reports/MinReporter.cfc b/system/reports/MinReporter.cfc index cee05918..b78dc1dd 100644 --- a/system/reports/MinReporter.cfc +++ b/system/reports/MinReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/html" ); } diff --git a/system/reports/MinTextReporter.cfc b/system/reports/MinTextReporter.cfc index ccb1fac3..0545afb2 100644 --- a/system/reports/MinTextReporter.cfc +++ b/system/reports/MinTextReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/plain" ); } diff --git a/system/reports/RawReporter.cfc b/system/reports/RawReporter.cfc index bfe63c84..338baa85 100644 --- a/system/reports/RawReporter.cfc +++ b/system/reports/RawReporter.cfc @@ -6,7 +6,6 @@ */ component extends="BaseReporter" { - /** * Get the name of the reporter */ @@ -27,7 +26,7 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ return arguments.results.getMemento(); diff --git a/system/reports/SimpleReporter.cfc b/system/reports/SimpleReporter.cfc index ecfebbd9..c9ebee4e 100644 --- a/system/reports/SimpleReporter.cfc +++ b/system/reports/SimpleReporter.cfc @@ -26,11 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/html" ); } diff --git a/system/reports/TapReporter.cfc b/system/reports/TapReporter.cfc index 2ffd1ef2..547bef1d 100644 --- a/system/reports/TapReporter.cfc +++ b/system/reports/TapReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/plain" ); } diff --git a/system/reports/TextReporter.cfc b/system/reports/TextReporter.cfc index 0b44a732..faad0281 100644 --- a/system/reports/TextReporter.cfc +++ b/system/reports/TextReporter.cfc @@ -26,10 +26,10 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { // content type getPageContextResponse().setContentType( "text/plain" ); } diff --git a/system/reports/XMLReporter.cfc b/system/reports/XMLReporter.cfc index 6d22569f..9ddace52 100644 --- a/system/reports/XMLReporter.cfc +++ b/system/reports/XMLReporter.cfc @@ -33,14 +33,17 @@ component extends="BaseReporter" { any function runReport( required testbox.system.TestResult results, required testbox.system.TestBox testbox, - struct options = {}, + struct options = {}, boolean justReturn = false ){ - if( !arguments.justReturn ){ + if ( !arguments.justReturn ) { resetHTMLResponse(); getPageContextResponse().setContentType( "application/xml" ); } - return variables.converter.toXML( data = arguments.results.getMemento(), rootName = "TestBox" ); + return variables.converter.toXML( + data = arguments.results.getMemento(), + rootName = "TestBox" + ); } } diff --git a/system/runners/BDDRunner.cfc b/system/runners/BDDRunner.cfc index 9f9651b4..aca8c279 100644 --- a/system/runners/BDDRunner.cfc +++ b/system/runners/BDDRunner.cfc @@ -21,7 +21,10 @@ component * @options The options for this runner * @testbox The TestBox class reference */ - function init( required struct options, required testBox ){ + function init( + required struct options, + required testBox + ){ variables.options = arguments.options; variables.testbox = arguments.testbox; @@ -44,7 +47,10 @@ component var bundleName = ( structKeyExists( targetMD, "displayName" ) ? targetMD.displayname : targetMD.name ); // Execute the suite descriptors - arguments.target.run( testResults = arguments.testResults, testbox = variables.testbox ); + arguments.target.run( + testResults = arguments.testResults, + testbox = variables.testbox + ); // Discover the test suite data to use for testing var testSuites = getTestSuites( arguments.target, targetMD ); @@ -73,10 +79,16 @@ component // find any methods annotated 'beforeAll' and execute them var beforeAllAnnotationMethods = variables.testbox .getUtility() - .getAnnotatedMethods( annotation = "beforeAll", metadata = getMetadata( arguments.target ) ); + .getAnnotatedMethods( + annotation = "beforeAll", + metadata = getMetadata( arguments.target ) + ); for ( var beforeAllMethod in beforeAllAnnotationMethods ) { - invoke( arguments.target, "#beforeAllMethod.name#" ); + invoke( + arguments.target, + "#beforeAllMethod.name#" + ); } // Iterate over found test suites and test them, if nested suites, then this will recurse as well. @@ -116,17 +128,26 @@ component // find any methods annotated 'afterAll' and execute them var afterAllAnnotationMethods = variables.testbox .getUtility() - .getAnnotatedMethods( annotation = "afterAll", metadata = getMetadata( arguments.target ) ); + .getAnnotatedMethods( + annotation = "afterAll", + metadata = getMetadata( arguments.target ) + ); for ( var afterAllMethod in afterAllAnnotationMethods ) { - invoke( arguments.target, "#afterAllMethod.name#" ); + invoke( + arguments.target, + "#afterAllMethod.name#" + ); } } catch ( Any e ) { bundleStats.globalException = e; // For a righteous man falls seven times, and rises (tests) again :) // The amount doesn't matter, nothing can run at this point, failure with before/after aspects that need fixing bundleStats.totalError = 7; - arguments.testResults.incrementStat( type = "error", count = bundleStats.totalError ); + arguments.testResults.incrementStat( + type = "error", + count = bundleStats.totalError + ); } } // end if we can run bundle diff --git a/system/runners/BaseRunner.cfc b/system/runners/BaseRunner.cfc index 8855b1a2..7b1f0dbf 100644 --- a/system/runners/BaseRunner.cfc +++ b/system/runners/BaseRunner.cfc @@ -13,7 +13,10 @@ component { * @incomingLabels The incoming labels to test against this runner's labels. * @testResults The testing results object */ - boolean function canRunLabel( required array incomingLabels, required testResults ){ + boolean function canRunLabel( + required array incomingLabels, + required testResults + ){ var labels = arguments.testResults.getLabels(); var excludes = arguments.testResults.getExcludes(); @@ -211,7 +214,12 @@ component { */ boolean function isValidTestMethod( required methodName, required target ){ // True if annotation "test" exists - if ( structKeyExists( getMetadata( arguments.target[ arguments.methodName ] ), "test" ) ) { + if ( + structKeyExists( + getMetadata( arguments.target[ arguments.methodName ] ), + "test" + ) + ) { return true; } // All xUnit test methods must start or end with the term, "test". diff --git a/system/runners/IRunner.cfc b/system/runners/IRunner.cfc index 5910b2e3..f5178ab5 100644 --- a/system/runners/IRunner.cfc +++ b/system/runners/IRunner.cfc @@ -11,7 +11,10 @@ interface { * @options The options for a runner * @testbox The TestBox class reference */ - function init( required struct options, required testbox ); + function init( + required struct options, + required testbox + ); /** * Execute a test run on a target bundle CFC diff --git a/system/runners/UnitRunner.cfc b/system/runners/UnitRunner.cfc index 1cc60b71..9a03a598 100644 --- a/system/runners/UnitRunner.cfc +++ b/system/runners/UnitRunner.cfc @@ -20,7 +20,10 @@ component * @options.hint The options for this runner * @testbox.hint The TestBox class reference */ - function init( required struct options, required testBox ){ + function init( + required struct options, + required testBox + ){ variables.options = arguments.options; variables.testbox = arguments.testbox; @@ -73,10 +76,16 @@ component // find any methods annotated 'beforeAll' and execute them var beforeAllAnnotationMethods = variables.testbox .getUtility() - .getAnnotatedMethods( annotation = "beforeAll", metadata = getMetadata( arguments.target ) ); + .getAnnotatedMethods( + annotation = "beforeAll", + metadata = getMetadata( arguments.target ) + ); for ( var beforeAllMethod in beforeAllAnnotationMethods ) { - invoke( arguments.target, "#beforeAllMethod.name#" ); + invoke( + arguments.target, + "#beforeAllMethod.name#" + ); } if ( structKeyExists( arguments.target, "beforeTests" ) ) { @@ -121,10 +130,16 @@ component // find any methods annotated 'afterAll' and execute them var afterAllAnnotationMethods = variables.testbox .getUtility() - .getAnnotatedMethods( annotation = "afterAll", metadata = getMetadata( arguments.target ) ); + .getAnnotatedMethods( + annotation = "afterAll", + metadata = getMetadata( arguments.target ) + ); for ( var afterAllMethod in afterAllAnnotationMethods ) { - invoke( arguments.target, "#afterAllMethod.name#" ); + invoke( + arguments.target, + "#afterAllMethod.name#" + ); } if ( structKeyExists( arguments.target, "afterTests" ) ) { @@ -135,7 +150,10 @@ component // For a righteous man falls seven times, and rises (tests) again :) // The amount doesn't matter, nothing can run at this point, failure with before/after aspects that need fixing bundleStats.totalError = 7; - arguments.testResults.incrementStat( type = "error", count = bundleStats.totalError ); + arguments.testResults.incrementStat( + type = "error", + count = bundleStats.totalError + ); } } @@ -327,7 +345,10 @@ component // labels attached to the suite for execution labels : ( structKeyExists( arguments.targetMD, "labels" ) ? listToArray( arguments.targetMD.labels ) : [] ), // the specs attached to this suite. - specs : getTestMethods( arguments.target, arguments.testResults ), + specs : getTestMethods( + arguments.target, + arguments.testResults + ), // the recursive suites suites : [] }; @@ -348,7 +369,10 @@ component * Retrieve the testing methods/specs from a given target. * @target.hint The target to get the methods from */ - private array function getTestMethods( required any target, required any testResults ){ + private array function getTestMethods( + required any target, + required any testResults + ){ var mResults = []; var methodArray = structKeyArray( arguments.target ); var index = 1; diff --git a/system/util/MixerUtil.cfc b/system/util/MixerUtil.cfc index 7043771c..e5c37851 100644 --- a/system/util/MixerUtil.cfc +++ b/system/util/MixerUtil.cfc @@ -3,7 +3,7 @@ Copyright Since 2005 TestBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com ******************************************************************************** -Author : Luis Majano +Author : Luis Majano Description : A utility object that provides runtime mixins -----------------------------------------------------------------------> @@ -174,7 +174,12 @@ A utility object that provides runtime mixins // Validate Property - if ( structKeyExists( evaluate( arguments.scope ), arguments.propertyName ) ) { + if ( + structKeyExists( + evaluate( arguments.scope ), + arguments.propertyName + ) + ) { "#arguments.scope#.#arguments.propertyName#" = arguments.propertyValue; } @@ -235,7 +240,10 @@ A utility object that provides runtime mixins - structDelete( evaluate( arguments.scope ), arguments.propertyName ); + structDelete( + evaluate( arguments.scope ), + arguments.propertyName + ); diff --git a/system/util/Util.cfc b/system/util/Util.cfc index 74191391..56759714 100644 --- a/system/util/Util.cfc +++ b/system/util/Util.cfc @@ -42,7 +42,10 @@ component { */ function fileLastModified( required filename ){ var objFile = createObject( "java", "java.io.File" ).init( - javacast( "string", getAbsolutePath( arguments.filename ) ) + javacast( + "string", + getAbsolutePath( arguments.filename ) + ) ); // Calculate adjustments fot timezone and daylightsavindtime var offset = ( ( getTimezoneInfo().utcHourOffset ) + 1 ) * -3600; @@ -146,7 +149,10 @@ component { * @annotation The annotation name to look for on methods * @metadata The metadata to search (recursively) for the provided annotation */ - public array function getAnnotatedMethods( required string annotation, required struct metadata ){ + public array function getAnnotatedMethods( + required string annotation, + required struct metadata + ){ var lifecycleMethods = []; if ( structKeyExists( arguments.metadata, "functions" ) ) { @@ -158,9 +164,15 @@ component { } if ( structKeyExists( arguments.metadata, "extends" ) ) { - arrayEach( getAnnotatedMethods( arguments.annotation, arguments.metadata.extends ), function( item ){ - arrayAppend( lifecycleMethods, arguments.item ); - } ); + arrayEach( + getAnnotatedMethods( + arguments.annotation, + arguments.metadata.extends + ), + function( item ){ + arrayAppend( lifecycleMethods, arguments.item ); + } + ); } return lifecycleMethods; diff --git a/tests/specs/AssertionsTest.cfc b/tests/specs/AssertionsTest.cfc index b92ecfed..c24254d7 100644 --- a/tests/specs/AssertionsTest.cfc +++ b/tests/specs/AssertionsTest.cfc @@ -39,7 +39,10 @@ component var message = "exception_message"; var target = function(){ - throw( type = "actual_type", message = message ); + throw( + type = "actual_type", + message = message + ); }; var assertionFailed = false; diff --git a/tests/specs/Assertionscf9Test.cfc b/tests/specs/Assertionscf9Test.cfc index 6cd2d386..8ec4e4d3 100644 --- a/tests/specs/Assertionscf9Test.cfc +++ b/tests/specs/Assertionscf9Test.cfc @@ -133,10 +133,16 @@ component $assert.isEqual( f1, f1 ); - $assert.isEqual( new testbox.system.MockBox(), new testbox.system.MockBox() ); + $assert.isEqual( + new testbox.system.MockBox(), + new testbox.system.MockBox() + ); var xmlString = ""; - $assert.isEqual( xmlParse( xmlString ), xmlParse( xmlString ) ); + $assert.isEqual( + xmlParse( xmlString ), + xmlParse( xmlString ) + ); $assert.isEqual( 0, 0 ); $assert.isEqual( "hello", "HEllO" ); @@ -217,7 +223,10 @@ component ) ); $assert.typeOf( "string", "hello string" ); - $assert.typeOf( "struct", { name : "luis", awesome : true } ); + $assert.typeOf( + "struct", + { name : "luis", awesome : true } + ); $assert.typeOf( "uuid", createUUID() ); $assert.typeOf( "url", "https://www.coldbox.org" ); } @@ -238,7 +247,10 @@ component } function testInstanceOf(){ - $assert.instanceOf( new testbox.system.MockBox(), "testbox.system.MockBox" ); + $assert.instanceOf( + new testbox.system.MockBox(), + "testbox.system.MockBox" + ); } function testNotInstanceOf(){ @@ -258,15 +270,24 @@ component } function testNotMatch(){ - $assert.notMatch( "This testing is my test", "(hello)$" ); + $assert.notMatch( + "This testing is my test", + "(hello)$" + ); } function testKey(){ - $assert.key( { name : "luis", awesome : true }, "awesome" ); + $assert.key( + { name : "luis", awesome : true }, + "awesome" + ); } function testNotKey(){ - $assert.notKey( { name : "luis", awesome : true }, "test" ); + $assert.notKey( + { name : "luis", awesome : true }, + "test" + ); } function testDeepKey(){ @@ -322,7 +343,10 @@ component */ function testExpectedExceptionNoValue(){ // This method should throw an invalid exception and pass - throw( type = "InvalidException", message = "This test method should pass with an expected exception" ); + throw( + type = "InvalidException", + message = "This test method should pass with an expected exception" + ); } /** @@ -350,19 +374,28 @@ component function testExpectedExceptionFromMethod(){ expectedException(); // This method should throw an invalid exception and pass - throw( type = "InvalidException", message = "This test method should pass with an expected exception" ); + throw( + type = "InvalidException", + message = "This test method should pass with an expected exception" + ); } function testExpectedExceptionFromMethodWithType(){ expectedException( "InvalidException" ); // This method should throw an invalid exception and pass - throw( type = "InvalidException", message = "This test method should pass with an expected exception" ); + throw( + type = "InvalidException", + message = "This test method should pass with an expected exception" + ); } function testExpectedExceptionFromMethodWithTypeAndRegex(){ expectedException( "InvalidException", "(pass with an)" ); // This method should throw an invalid exception and pass - throw( type = "InvalidException", message = "This test method should pass with an expected exception" ); + throw( + type = "InvalidException", + message = "This test method should pass with an expected exception" + ); } function testIsGT(){ @@ -381,7 +414,10 @@ component $assert.isLT( "a", "d" ); $assert.isLT( 5, 30 ); $assert.isLT( "01/01/2013", "01/02/2013" ); - $assert.isLT( "01/01/2013 08:00:00", "01/01/2013 12:00:00" ); + $assert.isLT( + "01/01/2013 08:00:00", + "01/01/2013 12:00:00" + ); } function testIsLTE(){ diff --git a/tests/specs/BDDTest.cfc b/tests/specs/BDDTest.cfc index 06b600f9..ec8823ed 100644 --- a/tests/specs/BDDTest.cfc +++ b/tests/specs/BDDTest.cfc @@ -354,15 +354,14 @@ component extends="testbox.system.BaseSpec" { } ); it( "can mock any type of data", function(){ - var data = mockData( name : "name", age : "age", id : "uuid" ); + var data = mockData( name: "name", age: "age", id: "uuid" ); debug( data ); expect( data ).notToBeEmpty(); } ); it( "can load the output utilities into request.testbox", function(){ - expect( request.testbox ) - .toHaveKey( "clearDebugBuffer,console,debug,print,println" ); - }); + expect( request.testbox ).toHaveKey( "clearDebugBuffer,console,debug,print,println" ); + } ); } ); } diff --git a/tests/specs/DebugTests.cfc b/tests/specs/DebugTests.cfc index c758803f..8fbed655 100644 --- a/tests/specs/DebugTests.cfc +++ b/tests/specs/DebugTests.cfc @@ -21,7 +21,10 @@ component extends="testbox.system.BaseSpec" { title = "Debug", body = function(){ it( "can have custom labels", function(){ - debug( var = [ 1, 2, 3, 4 ], label = "My Custom Label" ); + debug( + var = [ 1, 2, 3, 4 ], + label = "My Custom Label" + ); var buffer = getDebugBuffer(); expect( buffer[ 1 ].label ).toBe( "My Custom Label" ); } ); diff --git a/tests/specs/EdgeCases.cfc b/tests/specs/EdgeCases.cfc index be43f30b..c68582d8 100644 --- a/tests/specs/EdgeCases.cfc +++ b/tests/specs/EdgeCases.cfc @@ -9,8 +9,14 @@ component extends="testbox.system.BaseSpec" { expect( expected ).toBe( actual ); // this is line 10 } ); - it( "can handle private UDFs", variables.myFakeClosure ); - it( "can handle public UDFs", variables.myFakePublicClosure ); + it( + "can handle private UDFs", + variables.myFakeClosure + ); + it( + "can handle public UDFs", + variables.myFakePublicClosure + ); } ); describe( "Ability to bind data to life-cycle methods", function(){ diff --git a/tests/specs/MXUnitCompatTest.cfc b/tests/specs/MXUnitCompatTest.cfc index 56791b7c..92f41387 100644 --- a/tests/specs/MXUnitCompatTest.cfc +++ b/tests/specs/MXUnitCompatTest.cfc @@ -64,7 +64,10 @@ component extends="BaseTest" { function testAssertEquals(){ assertEquals( 4, 4 ); - assertEquals( { name : "luis", awesome : true }, { name : "luis", awesome : true } ); + assertEquals( + { name : "luis", awesome : true }, + { name : "luis", awesome : true } + ); assertEquals( "hello", "Hello" ); assertArrayEquals( [ 1, 2, 3 ], [ 1, 2, 3 ] ); } @@ -82,11 +85,23 @@ component extends="BaseTest" { } function testassertNotSame(){ - assertNotSame( this, createObject( "component", "testbox.system.MockBox" ) ); + assertNotSame( + this, + createObject( + "component", + "testbox.system.MockBox" + ) + ); // Even if the same CFC, two separate instances would be "equal" but not the "same". assertNotSame( - createObject( "component", "testbox.system.MockBox" ), - createObject( "component", "testbox.system.MockBox" ) + createObject( + "component", + "testbox.system.MockBox" + ), + createObject( + "component", + "testbox.system.MockBox" + ) ); } @@ -109,7 +124,10 @@ component extends="BaseTest" { } function testassertStructEquals(){ - assertStructEquals( { name : "luis", awesome : true }, { name : "luis", awesome : true } ); + assertStructEquals( + { name : "luis", awesome : true }, + { name : "luis", awesome : true } + ); } @@ -135,7 +153,10 @@ component extends="BaseTest" { */ function testExpectedExceptionNoValue(){ // This method should throw an invalid exception and pass - throw( type = "InvalidException", message = "This test method should pass with an expected exception" ); + throw( + type = "InvalidException", + message = "This test method should pass with an expected exception" + ); } /** @@ -152,13 +173,19 @@ component extends="BaseTest" { function testExpectedExceptionFromMethodWithType(){ expectedException( "InvalidException" ); // This method should throw an invalid exception and pass - throw( type = "InvalidException", message = "This test method should pass with an expected exception" ); + throw( + type = "InvalidException", + message = "This test method should pass with an expected exception" + ); } function testExpectedExceptionFromMethodWithTypeAndRegex(){ expectedException( "InvalidException", "(pass with an)" ); // This method should throw an invalid exception and pass - throw( type = "InvalidException", message = "This test method should pass with an expected exception" ); + throw( + type = "InvalidException", + message = "This test method should pass with an expected exception" + ); } function testMakePublic(){ @@ -176,7 +203,10 @@ component extends="BaseTest" { function testMakePublicWithPackage(){ variables.test = new tests.resources.somepackage.ComponentInDifferentPackage(); makepublic( variables.test, "aPackageMethod" ); - assertEquals( "test for this value", variables.test.aPackageMethod() ); + assertEquals( + "test for this value", + variables.test.aPackageMethod() + ); } private function privateMethodsDontRun(){ diff --git a/tests/specs/TestExecutionSequence.cfc b/tests/specs/TestExecutionSequence.cfc index 6cbd1e95..a9b63692 100644 --- a/tests/specs/TestExecutionSequence.cfc +++ b/tests/specs/TestExecutionSequence.cfc @@ -1,46 +1,40 @@ component extends="testbox.system.BaseSpec" { - function beforeAll(){ - debug("1. in beforeAll()
    "); - } - - function afterAll(){ - debug("8.in afterAll()
    "); - } - - - function run(){ - - describe("outer describe", function(){ - - aroundEach( function( spec, suite ){ - debug("3.. top of outer aroundEach()
    "); - // execute the spec - arguments.spec.body(); - debug("6.. bottom of outer aroundEach()
    "); - }); - - - describe("inner describe", function(){ - - beforeEach(function(){ - debug("2... in inner describe()'s beforeEach()
    "); - }); - - afterEach(function(){ - debug("7... in inner describe()'s afterEach()
    "); - }); - - it("tests the negative", function(){ - debug("4.... top of inner describe()'s first it()'s callback
    "); - expect(sgn(-1)).toBeLT(0); - debug("5.... bottom of inner describe()'s first it()'s callback
    "); - }); - - }); - - }); - - } - -} \ No newline at end of file + function beforeAll(){ + debug( "1. in beforeAll()
    " ); + } + + function afterAll(){ + debug( "8.in afterAll()
    " ); + } + + + function run(){ + describe( "outer describe", function(){ + aroundEach( function( spec, suite ){ + debug( "3.. top of outer aroundEach()
    " ); + // execute the spec + arguments.spec.body(); + debug( "6.. bottom of outer aroundEach()
    " ); + } ); + + + describe( "inner describe", function(){ + beforeEach( function(){ + debug( "2... in inner describe()'s beforeEach()
    " ); + } ); + + afterEach( function(){ + debug( "7... in inner describe()'s afterEach()
    " ); + } ); + + it( "tests the negative", function(){ + debug( "4.... top of inner describe()'s first it()'s callback
    " ); + expect( sgn( -1 ) ).toBeLT( 0 ); + debug( "5.... bottom of inner describe()'s first it()'s callback
    " ); + } ); + } ); + } ); + } + +} diff --git a/tests/specs/mockbox/MockBoxTest.cfc b/tests/specs/mockbox/MockBoxTest.cfc index 7f367315..e99ee2af 100755 --- a/tests/specs/mockbox/MockBoxTest.cfc +++ b/tests/specs/mockbox/MockBoxTest.cfc @@ -20,8 +20,7 @@ $assert.isEqual( 2, test.$count( "getData" ) ); // With DSL - test - .$reset() + test.$reset() .$( "getData" ) .$results( 1000 ); $assert.isEqual( 0, test.$count( "getData" ) ); @@ -35,7 +34,10 @@ Test = getMockBox().createMock( "testbox.tests.resources.Test" ); test.$( "virtualReturn" ).$results( "Virtual Called Baby!!" ); $assert.isEqual( 0, test.$count( "virtualReturn" ) ); - $assert.isEqual( "Virtual Called Baby!!", test.virtualReturn() ); + $assert.isEqual( + "Virtual Called Baby!!", + test.virtualReturn() + ); debug( test.$callLog() ); $assert.isTrue( structKeyExists( test.$callLog(), "virtualReturn" ) ); } @@ -61,7 +63,10 @@ } function testSpys(){ - Test = createObject( "component", "testbox.tests.resources.Test" ); + Test = createObject( + "component", + "testbox.tests.resources.Test" + ); getMockBox().prepareMock( test ); // mock un-spy methods $assert.isEqual( 5, test.getData() ); @@ -75,24 +80,43 @@ function testMockWithArguments(){ Test = getMockBox().createMock( "testbox.tests.resources.Test" ); // unmocked - $assert.isEqual( "/mockFactory", test.getSetting( "AppMapping" ) ); - $assert.isEqual( "NOT FOUND", test.getSetting( "DebugMode" ) ); + $assert.isEqual( + "/mockFactory", + test.getSetting( "AppMapping" ) + ); + $assert.isEqual( + "NOT FOUND", + test.getSetting( "DebugMode" ) + ); // Mock - test - .$( method = "getSetting", callLogging = true ) + test.$( + method = "getSetting", + callLogging = true + ) .$args( "AppMapping" ) .$results( "mockbox.testing" ); - test - .$( method = "getSetting", callLogging = true ) + test.$( + method = "getSetting", + callLogging = true + ) .$args( "DebugMode" ) .$results( "true" ); - $assert.isEqual( "mockbox.testing", test.getSetting( "AppMapping" ) ); - $assert.isEqual( "true", test.getSetting( "DebugMode" ) ); + $assert.isEqual( + "mockbox.testing", + test.getSetting( "AppMapping" ) + ); + $assert.isEqual( + "true", + test.getSetting( "DebugMode" ) + ); } function testCollaborator(){ - Test = createObject( "component", "testbox.tests.resources.Test" ); + Test = createObject( + "component", + "testbox.tests.resources.Test" + ); mockCollaborator = getMockBox().createMock( className = "testbox.tests.resources.Collaborator", callLogging = true @@ -176,7 +200,10 @@ test.displayData(); test.displayData(); $assert.isEqual( true, test.$verifyCallCount( 4 ) ); - $assert.isEqual( true, test.$verifyCallCount( 4, "displayData" ) ); + $assert.isEqual( + true, + test.$verifyCallCount( 4, "displayData" ) + ); } function testMockMethodCallCount(){ @@ -217,8 +244,7 @@ }; // 1: Mock with positional and all calls should validate. - test - .$( "getSetting" ) + test.$( "getSetting" ) .$args( args.string, args.integer, @@ -283,8 +309,7 @@ args.integer = 23; // 2. Mock with named values and all calls should validate. - test - .$( "getSetting" ) + test.$( "getSetting" ) .$args( string = args.string, integer = args.integer, @@ -409,11 +434,29 @@ mock.luis = "Majano"; mock.$property( "cool", "variables", true ).$property( "number", "variables.instance", 7 ); - $assert.isEqual( "Majano", mock.$getProperty( name = "luis", scope = "this" ) ); - $assert.isEqual( true, mock.$getProperty( name = "cool" ) ); - $assert.isEqual( true, mock.$getProperty( name = "cool", scope = "variables" ) ); - $assert.isEqual( 7, mock.$getProperty( name = "number", scope = "variables.instance" ) ); - $assert.isEqual( 7, mock.$getProperty( name = "number", scope = "instance" ) ); + $assert.isEqual( + "Majano", + mock.$getProperty( name = "luis", scope = "this" ) + ); + $assert.isEqual( + true, + mock.$getProperty( name = "cool" ) + ); + $assert.isEqual( + true, + mock.$getProperty( name = "cool", scope = "variables" ) + ); + $assert.isEqual( + 7, + mock.$getProperty( + name = "number", + scope = "variables.instance" + ) + ); + $assert.isEqual( + 7, + mock.$getProperty( name = "number", scope = "instance" ) + ); } function testStubWithInheritance(){ @@ -423,7 +466,12 @@ function testStubWithImplements(){ mock = getMockBox().createStub( implements = "coldbox.system.cache.ICacheProvider" ); - $assert.isTrue( isInstanceOf( mock, "coldbox.system.cache.ICacheProvider" ) ); + $assert.isTrue( + isInstanceOf( + mock, + "coldbox.system.cache.ICacheProvider" + ) + ); } function testContainsCFKeyword(){ @@ -438,19 +486,40 @@ mock = getMockBox().createStub(); mock.$( "mockMe", "Mocked" ); - $assert.isEqual( "Mocked", mock.mockMe( variables.testFunction ) ); - $assert.isEqual( "Mocked", mock.mockMe( test = variables.testFunction ) ); - $assert.isEqual( "Mocked", mock.mockMe( [ variables.testFunction ] ) ); - $assert.isEqual( "Mocked", mock.mockMe( test = [ variables.testFunction ] ) ); - $assert.isEqual( "Mocked", mock.mockMe( { mockData : variables.testFunction } ) ); - $assert.isEqual( "Mocked", mock.mockMe( test = { mockData : variables.testFunction } ) ); + $assert.isEqual( + "Mocked", + mock.mockMe( variables.testFunction ) + ); + $assert.isEqual( + "Mocked", + mock.mockMe( test = variables.testFunction ) + ); + $assert.isEqual( + "Mocked", + mock.mockMe( [ variables.testFunction ] ) + ); + $assert.isEqual( + "Mocked", + mock.mockMe( test = [ variables.testFunction ] ) + ); + $assert.isEqual( + "Mocked", + mock.mockMe( { mockData : variables.testFunction } ) + ); + $assert.isEqual( + "Mocked", + mock.mockMe( test = { mockData : variables.testFunction } ) + ); } function testInterfaceContracts(){ mock = getMockBox().createMock( "testbox.tests.resources.MyInterfaceMock" ); mock.$( "testThis", "mocked!" ); - $assert.isEqual( "mocked!", mock.testThis( "name", 35 ) ); + $assert.isEqual( + "mocked!", + mock.testThis( "name", 35 ) + ); } function testCFUDF(){ @@ -460,7 +529,12 @@ function testCallbacks(){ // shortcut - var mocked = getMockBox().createStub().$( method = "getAmigo", callback = variables.testFunction ); + var mocked = getMockBox() + .createStub() + .$( + method = "getAmigo", + callback = variables.testFunction + ); $assert.isEqual( mocked.getAmigo(), testFunction() ); // no arguments @@ -470,7 +544,10 @@ .$callback( variables.testFunction ); $assert.isEqual( mocked.getAmigo(), testFunction() ); // test argument passing - $assert.isEqual( mocked.getAmigo( "luis" ), testFunction( "luis" ) ); + $assert.isEqual( + mocked.getAmigo( "luis" ), + testFunction( "luis" ) + ); // with arguments var mocked = getMockBox() @@ -478,7 +555,10 @@ .$( "getAmigo" ) .$args( "luis" ) .$callback( variables.testFunction ); - $assert.isEqual( mocked.getAmigo( "luis" ), testFunction( "luis" ) ); + $assert.isEqual( + mocked.getAmigo( "luis" ), + testFunction( "luis" ) + ); } function test$Throws(){