Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Jul 28, 2023
2 parents b1ed39c + 19d52a6 commit 5572db8
Show file tree
Hide file tree
Showing 21 changed files with 951 additions and 336 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ You can support ColdBox and all of our Open Source initiatives at Ortus Solution

Thank you to all the people who have already contributed to ColdBox! We :heart: :heart: :heart: love you!


<a href = "https://github.com/ortus-solutions/testbox/graphs/contributors">
<img src = "https://contrib.rocks/image?repo=ortus-solutions/testbox"/>
</a>
Expand Down
6 changes: 4 additions & 2 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"TestBox",
"version":"5.1.0",
"version":"5.2.0",
"location":"https://downloads.ortussolutions.com/ortussolutions/testbox/@build.version@/testbox-@build.version@.zip",
"author":"Ortus Solutions <info@ortussolutions.com>",
"slug":"testbox",
Expand Down Expand Up @@ -58,8 +58,10 @@
"start:lucee":"server start serverConfigFile=server-lucee@5.json",
"start:2018":"server start serverConfigFile=server-adobe@2018.json",
"start:2021":"server start serverConfigFile=server-adobe@2021.json",
"start:2023":"server start serverConfigFile=server-adobe@2023.json",
"log:lucee":"server log testbox-lucee@5 --follow",
"log:2018":"server log testbox-adobe@2018 --follow",
"log:2021":"server log testbox-adobe@2021 --follow"
"log:2021":"server log testbox-adobe@2021 --follow",
"log:2023":"server log testbox-adobe@2023 --follow"
}
}
17 changes: 16 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### New Features

- [TESTBOX-375](https://ortussolutions.atlassian.net/browse/TESTBOX-375) Updated mixerUtil for faster performance and new approaches to dynamic mixins
- [TESTBOX-376](https://ortussolutions.atlassian.net/browse/TESTBOX-376) Add `bundlesPattern` to testbox.system.TestBox `init` method
- [TESTBOX-377](https://ortussolutions.atlassian.net/browse/TESTBOX-377) TestBox Modules

### Bugs

- [TESTBOX-346](https://ortussolutions.atlassian.net/browse/TESTBOX-346) `expect(sut).toBeInstanceOf("something")` breaks if sut is a query
- [TESTBOX-374](https://ortussolutions.atlassian.net/browse/TESTBOX-374) cbstreams doesn't entirely work outside of ColdBox

### Improvements

- [TESTBOX-20](https://ortussolutions.atlassian.net/browse/TESTBOX-20) toBeInstanceOf() Expectation handle Java classes

## [5.1.0] - 2023-07-06

### Added
Expand Down Expand Up @@ -39,7 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [TESTBOX-355](https://ortussolutions.atlassian.net/browse/TESTBOX-355) Add debugBuffer to JSONReporter
- [TESTBOX-366](https://ortussolutions.atlassian.net/browse/TESTBOX-366) ANTJunit Reporter better visualization of the fail origin and details
- [TESTBOX-368](https://ortussolutions.atlassian.net/browse/TESTBOX-368) Support list of Directories for HTMLRunner to allow more modular tests structure
- [TESTBOX-370](https://ortussolutions.atlassian.net/browse/TESTBOX-370) \`toHaveKey\` works on queries in Lucee but not ColdFusion
- [TESTBOX-370](https://ortussolutions.atlassian.net/browse/TESTBOX-370) `toHaveKey` works on queries in Lucee but not ColdFusion

### Added

Expand Down
10 changes: 8 additions & 2 deletions system/Assertion.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,16 @@ component {
required string typeName,
message = ""
){
var md = getMetadata( arguments.actual );
var actualType = isStruct( md ) && md.keyExists( "name" ) ? md.name : actual.getClass().getName();
arguments.message = (
len( arguments.message ) ? arguments.message : "The actual is of type [#getMetadata( actual ).name ?: "n/a"#] which is not the expected type of [#arguments.typeName#]"
len( arguments.message ) ? arguments.message : "The actual is of type [#actualType#] which is not the expected type of [#arguments.typeName#]"
);

if ( isInstanceOf( arguments.actual, arguments.typeName ) ) {
return this;
}

fail( arguments.message );
}

Expand All @@ -306,8 +310,10 @@ component {
required string typeName,
message = ""
){
var md = getMetadata( arguments.actual );
var actualType = isStruct( md ) && md.keyExists( "name" ) ? md.name : actual.getClass().getName();
arguments.message = (
len( arguments.message ) ? arguments.message : "The actual is of type [#getMetadata( actual ).name ?: "n/a"#] which is the expected type of [#arguments.typeName#]"
len( arguments.message ) ? arguments.message : "The actual is of type [#actualType#] which is the expected type of [#arguments.typeName#]"
);
if ( !isInstanceOf( arguments.actual, arguments.typeName ) ) {
return this;
Expand Down
63 changes: 59 additions & 4 deletions system/BaseSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,10 @@ component {
getPageContext().getResponse().setContentType( "text/html" );
// run tests
var runner = new testbox.system.TestBox(
bundles = "#getMetadata( this ).name#",
labels = arguments.labels,
reporter = arguments.reporter,
options = { coverage : { enabled : false } }
bundles : "#getMetadata( this ).name#",
labels : arguments.labels,
reporter: arguments.reporter,
options : { coverage : { enabled : false } }
);
// Produce report
writeOutput( runner.run( testSuites = arguments.testSuites, testSpecs = arguments.testSpecs ) );
Expand Down Expand Up @@ -974,6 +974,19 @@ component {
specStats.failDetail = e.detail;
// Increment recursive pass stats
arguments.testResults.incrementSpecStat( type = "skipped", stats = specStats );
// Module call backs
arguments.runner
.getTestBox()
.announceToModules(
"onSpecSkipped",
[
arguments.spec,
specStats,
arguments.suite,
arguments.suiteStats,
arguments.testResults
]
);
}
// Catch Fail() calls
catch ( "TestBox.AssertionFailed" e ) {
Expand All @@ -987,6 +1000,20 @@ component {

// Increment recursive pass stats
arguments.testResults.incrementSpecStat( type = "fail", stats = specStats );
// Module call backs
arguments.runner
.getTestBox()
.announceToModules(
"onSpecFailure",
[
e,
arguments.spec,
specStats,
arguments.suite,
arguments.suiteStats,
arguments.testResults
]
);
}
// Catch errors
catch ( any e ) {
Expand All @@ -1001,6 +1028,21 @@ component {

// Increment recursive pass stats
arguments.testResults.incrementSpecStat( type = "error", stats = specStats );

// Module call backs
arguments.runner
.getTestBox()
.announceToModules(
"onSpecError",
[
e,
arguments.spec,
specStats,
arguments.suite,
arguments.suiteSpecs,
arguments.testResults
]
);
} finally {
// Complete spec testing
arguments.testResults.endStats( specStats );
Expand Down Expand Up @@ -1501,6 +1543,19 @@ component {
return variables.$utility;
}

/**
* Get the TestBox Env object
*
* @return testbox.system.util.Env
*/
function getEnv(){
// Lazy Load it
if ( isNull( variables.$env ) ) {
variables.$env = new testbox.system.util.Env();
}
return variables.$env;
}

/**
* Get a reference to the MockBox Engine
*
Expand Down
26 changes: 24 additions & 2 deletions system/Expectation.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,26 @@ component accessors="true" {
* @needle The substring to find in a string or the value to find in an array
* @message The message to send in the failure
*/
function toContain( required any needle, message = "" ){
return toInclude( argumentCollection = arguments );
}

/**
* Assert that the given "needle" argument exists in the incoming string or array with case-sensitivity
*
* @needle The substring to find in a string or the value to find in an array
* @message The message to send in the failure
*/
function toContainWithCase( required any needle, message = "" ){
return toIncludeWithCase( argumentCollection = arguments );
}

/**
* Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity
*
* @needle The substring to find in a string or the value to find in an array
* @message The message to send in the failure
*/
function toInclude( required any needle, message = "" ){
arguments.target = this.actual;
if ( this.isNot ) {
Expand Down Expand Up @@ -599,14 +619,16 @@ component accessors="true" {
}

/**
* Assert that the actual value passes a given truth test (function/closure)
* Assert that the actual value passes a given truth test (function/closure/lambda)
*
* @target The target truth test function/closure
* @message The message to send in the failure
*/
function toSatisfy( required any target, message = "" ){
var actualMessage = isSimpleValue( this.actual ) ? this.actual : "The actual (complex) value";

arguments.message = (
len( arguments.message ) ? arguments.message : "The actual [#this.actual#] does not pass the truth test"
len( arguments.message ) ? arguments.message : "The actual [#actualMessage#] does not pass the truth test"
);

var isPassed = arguments.target( this.actual );
Expand Down
Loading

0 comments on commit 5572db8

Please sign in to comment.