Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Jun 16, 2021
2 parents 7008519 + ba63107 commit ac24c7b
Show file tree
Hide file tree
Showing 15 changed files with 287 additions and 193 deletions.
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"TestBox",
"version":"4.3.1",
"version":"4.4.0",
"location":"https://downloads.ortussolutions.com/ortussolutions/testbox/@build.version@/[email protected]@.zip",
"author":"Ortus Solutions <[email protected]>",
"slug":"testbox",
Expand Down
42 changes: 31 additions & 11 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

----

## [4.4.0] => 2021-JUN-16

### Fixed

- [TESTBOX-320](https://ortussolutions.atlassian.net/browse/TESTBOX-320) Runner tries to instantiate abstract classes
- [TESTBOX-319](https://ortussolutions.atlassian.net/browse/TESTBOX-319) Fix HTTP Status Headers Being Removed By Reporters when resetting html head
- [TESTBOX-318](https://ortussolutions.atlassian.net/browse/TESTBOX-318) Chaining "not" matchers before regular matchers doesn't work correctly
- [TESTBOX-316](https://ortussolutions.atlassian.net/browse/TESTBOX-316) Coverage output doesn't escape ending script tag
- [TESTBOX-315](https://ortussolutions.atlassian.net/browse/TESTBOX-315) ConsoleReporter fails with missing functions in assets/text
- [TESTBOX-313](https://ortussolutions.atlassian.net/browse/TESTBOX-313) No matching function \[SPACE\] found
- [TESTBOX-311](https://ortussolutions.atlassian.net/browse/TESTBOX-311) CF error variable \[THISBUNDLE\] doesn't exist when running tests

### Changed

- [TESTBOX-317](https://ortussolutions.atlassian.net/browse/TESTBOX-317) Full Null Support Some items of array can be NULL
- [TESTBOX-314](https://ortussolutions.atlassian.net/browse/TESTBOX-314) text and min text whitespace management
- [TESTBOX-301](https://ortussolutions.atlassian.net/browse/TESTBOX-301) notToBeBetween seems to be the same as toBeBetween

----

## [4.3.1] => 2021-MAY-25

### Fixed
Expand Down Expand Up @@ -43,34 +63,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

* [TESTBOX-294](https://ortussolutions.atlassian.net/browse/TESTBOX-294) - root path in test browser not enforced
- [TESTBOX-294](https://ortussolutions.atlassian.net/browse/TESTBOX-294) - root path in test browser not enforced

----

## [4.2.0] => 2020-NOV-19

### Fixed

* [TESTBOX-281](https://ortussolutions.atlassian.net/browse/TESTBOX-281) - request.testbox: Component ... has no accessible Member with name [$TESTID]
* [TESTBOX-290](https://ortussolutions.atlassian.net/browse/TESTBOX-290) - Turning on &quot;Prefix serialized JSON with&quot; in ACF causes issues in code coverage report
* [TESTBOX-293](https://ortussolutions.atlassian.net/browse/TESTBOX-293) - Force properties file to have properties extension and escape special chars
- [TESTBOX-281](https://ortussolutions.atlassian.net/browse/TESTBOX-281) - request.testbox: Component ... has no accessible Member with name [$TESTID]
- [TESTBOX-290](https://ortussolutions.atlassian.net/browse/TESTBOX-290) - Turning on &quot;Prefix serialized JSON with&quot; in ACF causes issues in code coverage report
- [TESTBOX-293](https://ortussolutions.atlassian.net/browse/TESTBOX-293) - Force properties file to have properties extension and escape special chars

### Added

* [TESTBOX-291](https://ortussolutions.atlassian.net/browse/TESTBOX-291) - refactor usage of locks for debug utility in specs
- [TESTBOX-291](https://ortussolutions.atlassian.net/browse/TESTBOX-291) - refactor usage of locks for debug utility in specs

----

## [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]
- [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
- [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
72 changes: 30 additions & 42 deletions system/Expectation.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ 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
Expand All @@ -80,18 +77,22 @@ component accessors="true" {
len( arguments.missingMethodName ) - 3
);
// set isNot pivot on this matcher
this.isNot = true;
try {
this.isNot = true;

// execute the dynamic method
var results = invoke(
this,
arguments.missingMethodName,
arguments.missingMethodArguments
);
if ( !isNull( results ) ) {
return results;
} else {
return;
// execute the dynamic method
var results = invoke(
this,
arguments.missingMethodName,
arguments.missingMethodArguments
);
if ( !isNull( results ) ) {
return results;
} else {
return;
}
} finally {
this.isNot = false;
}
}

Expand All @@ -103,22 +104,15 @@ 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 );
Expand Down Expand Up @@ -198,10 +192,7 @@ 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 );
Expand Down Expand Up @@ -240,10 +231,7 @@ 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 );
Expand Down Expand Up @@ -365,11 +353,7 @@ component accessors="true" {
* @regex Match this regex against the message of the exception
* @message The message to send in the failure
*/
function toThrow(
type = "",
regex = ".*",
message = ""
){
function toThrow( type = "", regex = ".*", message = "" ){
arguments.target = this.actual;
if ( this.isNot ) {
variables.assert.notThrows( argumentCollection = arguments );
Expand Down Expand Up @@ -422,15 +406,19 @@ component accessors="true" {
){
arguments.actual = this.actual;
if ( this.isNot ) {
var pass = false;
try {
variables.assert.between( argumentCollection = arguments );
} catch ( Any e ) {
pass = true;
}
if ( !pass ) {
arguments.message = (
len( arguments.message ) ? arguments.message : "The actual [#this.actual#] is actually between [#arguments.min#] and [#arguments.max#]"
);
variables.assert.fail( arguments.message );
} catch ( Any e ) {
return this;
}
return this;
} else {
variables.assert.between( argumentCollection = arguments );
}
Expand Down
44 changes: 33 additions & 11 deletions system/TestBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,15 @@ component accessors="true" {
variables.reporter = arguments.reporter;
}
// run it and get results
var results = runRaw( argumentCollection = arguments );
var results = runRaw( argumentCollection = arguments );
// store latest results
variables.result = results;
// return report
return produceReport( results );
var report = produceReport( results );
// set response headers
sendStatusHeaders( results );

return report;
}

/**
Expand Down Expand Up @@ -272,6 +276,7 @@ component accessors="true" {
if ( getComponentMetadata( thisBundlePath ).type eq "interface" ) {
continue;
}

// Execute Bundle
testBundle(
bundlePath = thisBundlePath,
Expand Down Expand Up @@ -305,8 +310,6 @@ component accessors="true" {

coverageService.endCapture( true );

sendStatusHeaders( results );

return results;
}

Expand Down Expand Up @@ -382,11 +385,10 @@ component accessors="true" {
// run it and get results
var results = runRaw( argumentCollection = arguments );

// check if reporter is "raw" and if raw, just return it
// check if reporter is "raw" and if raw, just return it else output the results
if ( variables.reporter.type == "raw" ) {
return produceReport( results );
} else {
// return report
writeOutput( produceReport( results ) );
}

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

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

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

// check if base spec assigned
Expand Down
3 changes: 3 additions & 0 deletions system/coverage/browser/CodeBrowser.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ component accessors=true {
var relPathToRoot = repeatString( "../", levelsFromRoot - 1 );
var brush = right( fileData.relativeFilePath, 4 ) == ".cfm" ? "coldfusion" : "javascript";

// Escape closing script tags to avoid breaking out of code display early
fileContents = REReplace(fileContents, '</script>', '&lt;/script>', 'all');

savecontent variable="local.fileTemplate" {
include "templates/file.cfm";
}
Expand Down
12 changes: 8 additions & 4 deletions system/reports/ConsoleReporter.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright Since 2005 TestBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
* ---
* A text reporter
* A text reporter that emits to the console via java System out.
*/
component extends="BaseReporter" {
component extends="TextReporter" {

function init(){
variables.out = createObject( "Java", "java.lang.System" ).out;
Expand Down Expand Up @@ -41,14 +41,18 @@ component extends="BaseReporter" {

// bundle stats
variables.bundleStats = arguments.results.getBundleStats();

// prepare the report
savecontent variable="local.report" {
include "assets/text.cfm";
}

// send to console
variables.out.printLn( local.report );
variables.out.printLn( reReplace(
trim( local.report ),
"[\r\n]+",
chr( 10 ),
"all"
) );

return "Report Sent To Console";
}
Expand Down
7 changes: 6 additions & 1 deletion system/reports/MinTextReporter.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ component extends="TextReporter" {
savecontent variable="local.report" {
include "assets/mintext.cfm";
}
return trim( local.report );
return reReplace(
trim( local.report ),
"[\r\n]+",
chr( 10 ),
"all"
);
}

}
Loading

0 comments on commit ac24c7b

Please sign in to comment.