-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
756 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
<bx:script> | ||
// GLOBAL VARIABLES | ||
ASSETS_DIR = expandPath( "/testbox/system/reports/assets" ); | ||
TESTBOX_VERSION = new testBox.system.TestBox().getVersion(); | ||
// TEST LOCATIONS -> UPDATE AS YOU SEE FIT | ||
rootMapping = "/tests/specs"; | ||
|
||
// Local Variables | ||
rootPath = expandPath( rootMapping ); | ||
targetPath = rootPath; | ||
|
||
// Incoming Navigation | ||
param name="url.path" default=""; | ||
if( len( url.path ) ){ | ||
targetPath = getCanonicalPath( rootpath & "/" & url.path ); | ||
// Avoid traversals, reset to root | ||
if( !findNoCase( rootpath, targetPath ) ){ | ||
targetPath = rootpath; | ||
} | ||
} | ||
|
||
// Get the actual execution path | ||
executePath = rootMapping & ( len( url.path ) ? "/#url.path#" : "/" ); | ||
// Execute an incoming path | ||
if( !isNull( url.action ) ){ | ||
if( directoryExists( targetPath ) ){ | ||
writeOutput( "#new testbox.system.TestBox( directory=executePath ).run()#" ); | ||
} else { | ||
writeOutput( "<h2>Invalid Directory: #encodeForHTML( targetPath )#</h2>" ); | ||
} | ||
abort; | ||
} | ||
|
||
// Get the tests to navigate | ||
qResults = directoryList( targetPath, false, "query", "", "name" ); | ||
|
||
// Calculate the back navigation path | ||
if( len( url.path ) ){ | ||
backPath = url.path.listToArray( "/\" ); | ||
backPath.pop(); | ||
backPath = backPath.toList( "/" ); | ||
} | ||
</bx:script> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="generator" content="TestBox v#TESTBOX_VERSION#"> | ||
<title>TestBox Browser</title> | ||
<bx:output> | ||
<style>#fileRead( '#ASSETS_DIR#/css/main.css' )#</style> | ||
<script>#fileRead( '#ASSETS_DIR#/js/jquery-3.3.1.min.js' )#</script> | ||
<script>#fileRead( '#ASSETS_DIR#/js/popper.min.js' )#</script> | ||
<script>#fileRead( '#ASSETS_DIR#/js/bootstrap.min.js' )#</script> | ||
<script>#fileRead( '#ASSETS_DIR#/js/stupidtable.min.js' )#</script> | ||
</bx:output> | ||
</head> | ||
<bx:output> | ||
<body> | ||
|
||
<div id="tb-runner" class="container"> | ||
|
||
<!--- Header ---> | ||
<div class="row"> | ||
<div class="col-md-4 text-center mx-auto"> | ||
<img class="mt-3" src="http://www.ortussolutions.com/__media/testbox-185.png" alt="TestBox" id="tb-logo"/> | ||
<br> | ||
v#TESTBOX_VERSION# | ||
<br> | ||
<a | ||
href="index.cfm?action=runTestBox&path=#URLEncodedFormat( url.path )#" | ||
target="_blank" | ||
> | ||
<button | ||
class="btn btn-primary btn-sm my-1" | ||
type="button"> | ||
Run All | ||
</button> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<!--- Runners ---> | ||
<div class="row"> | ||
<div class="col-md-12 mb-4"> | ||
<h2>Availble Test Runners: </h2> | ||
<p> | ||
Below is a listing of the runners matching the "runner*.cfm" pattern. | ||
</p> | ||
|
||
<bx:set runners = directoryList( expandPath( "./" ), false, "query", "runner*.cfm" )> | ||
<bx:output query="runners"> | ||
<a href="#runners.name#" target="_blank" class="btn btn-secondary btn-sm my-1 mx-1">#runners.name#</a> | ||
</bx:output> | ||
</div> | ||
</div> | ||
|
||
<!--- Listing ---> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<form name="runnerForm" id="runnerForm"> | ||
<input type="hidden" name="opt_run" id="opt_run" value="true"> | ||
<h2>TestBox Test Browser: </h2> | ||
<p> | ||
Below is a listing of the files and folders starting from your root <code>#rootMapping#</code>. You can click on individual tests in order to execute them | ||
or click on the <strong>Run All</strong> button on your left and it will execute a directory runner from the visible folder. | ||
</p> | ||
|
||
<fieldset> | ||
<legend>#targetPath.replace( rootPath, "" )#</legend> | ||
|
||
<!--- Show Back If we are traversing ---> | ||
<bx:if len( url.path )> | ||
<a href="index.cfm?path=#URLEncodedFormat( backPath )#"> | ||
<button type="button" class="btn btn-secondary btn-sm my-1">&##xAB; Back</button> | ||
</a> | ||
<br> | ||
<hr> | ||
</bx:if> | ||
|
||
<bx:loop query="qResults"> | ||
<!--- Skip . folder file names ---> | ||
<bx:if refind( "^\.", qResults.name )> | ||
<bx:continue> | ||
</bx:if> | ||
|
||
<bx:if qResults.type eq "Dir"> | ||
<a | ||
class="btn btn-secondary btn-sm my-1" | ||
href="index.cfm?path=#urlEncodedFormat( url.path & "/" & qResults.name )#" | ||
> | ||
&##x271A; #qResults.name# | ||
</a> | ||
<br /> | ||
<bx:elseif listLast( qresults.name, ".") eq "cfm"> | ||
<a | ||
class="btn btn-primary btn-sm my-1" | ||
href="#executePath & "/" & qResults.name#" | ||
target="_blank" | ||
> | ||
#qResults.name# | ||
</a> | ||
<br /> | ||
<bx:elseif listLast( qresults.name, ".") eq "cfc" and qresults.name neq "Application.cfc"> | ||
<a | ||
class="btn btn-primary btn-sm my-1" | ||
href="#executePath & "/" & qResults.name#?method=runRemote" | ||
target="_blank" | ||
> | ||
#qResults.name# | ||
</a> | ||
<br /> | ||
<bx:else> | ||
#qResults.name# | ||
<br/> | ||
</bx:if> | ||
</bx:loop> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> | ||
</bx:output> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright Since 2005 Ortus Solutions, Corp | ||
* www.ortussolutions.com | ||
* ************************************************************************************* | ||
* This is the test harness application file that will be executed by the TestBox in isolation | ||
* to a root application. Usually you mimic your application's Application.bx settings here. | ||
*/ | ||
class { | ||
this.name = "My Test Harness"; | ||
|
||
// The mapping to easily access the tests | ||
this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() ); | ||
// The mapping to easily access the root application usually the parent folder | ||
this.mappings[ "/root" ] = expandPath( "/../" ); | ||
//this.mappings[ "/testbox" ] = expandPath( "/../" ); | ||
|
||
// Any application settings go here | ||
|
||
/** | ||
* Executes BEFORE any runner or test requested. | ||
*/ | ||
boolean function onRequestStart( String targetPage ){ | ||
return true; | ||
} | ||
|
||
/** | ||
* Executes AFTER any runner or test requested. | ||
*/ | ||
void function onRequestEnd( String targetPage ){ | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!--- Executes all tests in the 'specs' folder with simple reporter by default ---> | ||
<bx:param name="url.reporter" default="simple"> | ||
<bx:param name="url.directory" default="tests.specs"> | ||
<bx:param name="url.recurse" default="true" type="boolean"> | ||
<bx:param name="url.bundles" default=""> | ||
<bx:param name="url.labels" default=""> | ||
<bx:param name="url.excludes" default=""> | ||
<bx:param name="url.reportpath" default="#expandPath( "/tests/results" )#"> | ||
<bx:param name="url.propertiesFilename" default="TEST.properties"> | ||
<bx:param name="url.propertiesSummary" default="false" type="boolean"> | ||
<bx:param name="url.editor" default="vscode"> | ||
<bx:param name="url.bundlesPattern" default="*Spec*.cfc|*Test*.cfc|*Spec*.bx|*Test*.bx"> | ||
|
||
<!--- Code Coverage requires FusionReactor ---> | ||
<bx:param name="url.coverageEnabled" default="false"> | ||
<bx:param name="url.coveragePathToCapture" default="#expandPath( '/root' )#"> | ||
<bx:param name="url.coverageWhitelist" default=""> | ||
<bx:param name="url.coverageBlacklist" default="/testbox,/coldbox,/tests,/modules,Application.cfc,/index.cfm,Application.bx,/index.bxm"> | ||
<!---<bx:param name="url.coverageBrowserOutputDir" default="#expandPath( '/tests/results/coverageReport' )#">---> | ||
<!---<bx:param name="url.coverageSonarQubeXMLOutputPath" default="#expandPath( '/tests/results/SonarQubeCoverage.xml' )#">---> | ||
<!--- Enable batched code coverage reporter, useful for large test bundles which require spreading over multiple testbox run commands. ---> | ||
<!--- <bx:param name="url.isBatched" default="false"> ---> | ||
|
||
<!--- Include the TestBox HTML Runner ---> | ||
<bx:include template="/testbox/system/runners/HTMLRunner.cfm" > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/** | ||
* My first spec file | ||
*/ | ||
class extends="testbox.system.BaseSpec" { | ||
|
||
/** | ||
* You can prepare variables here that will be available to all specs in this spec file | ||
*/ | ||
property testbox; | ||
property foo; | ||
property salvador; | ||
|
||
/*********************************** LIFE CYCLE Methods ***********************************/ | ||
|
||
/** | ||
* Executes BEFORE all suites in this spec file | ||
*/ | ||
function beforeAll(){ | ||
variables.salvador = 1; | ||
} | ||
|
||
/** | ||
* Executes AFTER all suites in this spec file | ||
*/ | ||
function afterAll(){ | ||
// do cleanup here | ||
} | ||
|
||
/*********************************** BDD SUITES ***********************************/ | ||
|
||
function run(){ | ||
/** | ||
* describe() starts a suite group of spec tests. It is the main BDD construct. | ||
* You can also use the aliases: story(), feature(), scenario(), given(), when() | ||
* to create fluent chains of human-readable expressions. | ||
* | ||
* Arguments: | ||
* | ||
* @title Required: The title of the suite, Usually how you want to name the desired behavior | ||
* @body Required: A closure that will resemble the tests to execute. | ||
* @labels The list or array of labels this suite group belongs to | ||
* @asyncAll If you want to parallelize the execution of the defined specs in this suite group. | ||
* @skip A flag that tells TestBox to skip this suite group from testing if true | ||
* @focused A flag that tells TestBox to only run this suite and no other | ||
*/ | ||
describe( "A spec", () => { | ||
/** | ||
* -------------------------------------------------------------------------- | ||
* Runs before each spec in THIS suite group or nested groups | ||
* -------------------------------------------------------------------------- | ||
*/ | ||
beforeEach( () => { | ||
testbox = 0; | ||
testbox++; | ||
} ); | ||
|
||
/** | ||
* -------------------------------------------------------------------------- | ||
* Runs after each spec in THIS suite group or nested groups | ||
* -------------------------------------------------------------------------- | ||
*/ | ||
afterEach( () => { | ||
foo = 0; | ||
} ); | ||
|
||
/** | ||
* it() describes a spec to test. Usually the title is prefixed with the suite name to create an expression. | ||
* You can also use the aliases: then(), test() to create fluent chains of human-readable expressions. | ||
* | ||
* Arguments: | ||
* | ||
* @title The title of this spec | ||
* @body The closure that represents the test | ||
* @labels The list or array of labels this spec belongs to | ||
* @skip A flag or a closure that tells TestBox to skip this spec test from testing if true. If this is a closure it must return boolean. | ||
* @data A struct of data you would like to bind into the spec so it can be later passed into the executing body function | ||
* @focused A flag that tells TestBox to only run this spec and no other | ||
*/ | ||
it( "can test for equality", () => { | ||
expect( testbox ).toBe( 1 ); | ||
} ); | ||
|
||
it( "can have more than one expectation to test", () => { | ||
testbox = testbox * 8; | ||
// type checks | ||
expect( testbox ).toBeTypeOf( "numeric" ); | ||
// dynamic type methods | ||
expect( testbox ).toBeNumeric(); | ||
// delta ranges | ||
expect( testbox ).toBeCloseTo( expected = 10, delta = 2 ); | ||
} ); | ||
|
||
it( "can have negative expectations", () => { | ||
testbox = testbox * 8; | ||
// type checks | ||
expect( testbox ).notToBeTypeOf( "usdate" ); | ||
// dynamic type methods | ||
expect( testbox ).notToBeArray(); | ||
// delta ranges | ||
expect( testbox ).notToBeCloseTo( expected = 10, delta = 2 ); | ||
} ); | ||
|
||
xit( "can have tests that can be skipped easily like this one by prefixing it with x", () => { | ||
fail( "xit() this should skip" ); | ||
} ); | ||
|
||
it( | ||
title = "can have tests that execute if the right environment exists (Windows Only)", | ||
body = () => { | ||
expect( server.os.name ).toInclude( "Windows" ); | ||
}, | ||
skip = ( !isWindows() ) | ||
); | ||
|
||
it( | ||
title = "can have tests that execute if the right environment exists (Mac Only)", | ||
body = () => { | ||
expect( server.os.name ).toInclude( "Mac" ); | ||
}, | ||
skip = ( !isMac() ) | ||
); | ||
} ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class extends="testbox.system.BaseSpec"{ | ||
|
||
function run(){ | ||
describe( "My First Test", ()=>{ | ||
test( "it can add", ()=>{ | ||
expect( sum( 1, 2 ) ).toBe( 3 ) | ||
} ) | ||
} ) | ||
} | ||
|
||
private function sum( a, b ){ | ||
return a + b | ||
} | ||
|
||
} |
Oops, something went wrong.