Test Harness
Every ColdBox application template comes with a nice test harness inside of a tests folder.
Here is a breakdown of what it contains:
    Application.cfc - A unique application file for your test harness. It should mimic exactly the one in your root application folder
    resources - Some basic testing resources or any of your own testing resources
    results - Where automated results are archived
    runner.cfm - The HTML runner for your test bundles
    specs - Where you will be writing your testing bundle specs for integration testing, unit testing and module testing.
    test.xml - Your ANT runner

Application.cfc

The Application.cfc for your tests is extremly important as it should mimic your applications real Application.cfc.
1
component{
2
3
// APPLICATION CFC PROPERTIES
4
this.name = "ColdBoxTestingSuite" & hash(getCurrentTemplatePath());
5
this.sessionManagement = true;
6
this.sessionTimeout = createTimeSpan( 0, 0, 15, 0 );
7
this.applicationTimeout = createTimeSpan( 0, 0, 15, 0 );
8
this.setClientCookies = true;
9
10
// Create testing mapping
11
this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() );
12
// Map back to its root
13
rootPath = REReplaceNoCase( this.mappings[ "/tests" ], "tests(\\|/)", "" );
14
this.mappings["/root"] = rootPath;
15
16
public void function onRequestEnd() {
17
18
if( !isNull( application.cbController ) ){
19
application.cbController.getLoaderService().processShutdown();
20
}
21
22
structDelete( application, "cbController" );
23
structDelete( application, "wirebox" );
24
}
25
}
Copied!
Please note that we provide already a mapping to your root application via /root and a mapping to the tests themselves via /tests . We would recommend you add any ORM specs here or any other mappings here as well.
Tip: Make sure all the same settings and configs from your root Application.cfc are replicated in your tests Application.cfc
Last modified 1yr ago
Copy link