ANT Runner
In our test samples and templates we include an ANT runner that will be able to execute your tests via ANT. It can also leverage our ANTJunit reporter to use the junitreport task to produce JUnit compliant reports as well. You can find this runner in the test samples and runner template directory.
1
<cfsetting showDebugOutput="false">
2
<cfparam name="url.reporter" default="simple">
3
<cfparam name="url.directory" default="test.specs">
4
<cfparam name="url.recurse" default="true" type="boolean">
5
<cfparam name="url.bundles" default="">
6
<cfparam name="url.labels" default="">
7
<cfparam name="url.reportpath" default="#expandPath( "/tests/results" )#">
8
<cfscript>
9
// prepare for tests for bundles or directories
10
if( len( url.bundles ) ){
11
testbox = new testbox.system.TestBox( bundles=url.bundles, labels=url.labels );
12
}
13
else{
14
testbox = new testbox.system.TestBox( directory={ mapping=url.directory, recurse=url.recurse}, labels=url.labels );
15
}
16
// Run Tests using correct reporter
17
results = testbox.run( reporter=url.reporter );
18
// do stupid JUnitReport task processing, if the report is ANTJunit
19
if( url.reporter eq "ANTJunit" ){
20
xmlReport = xmlParse( results );
21
for( thisSuite in xmlReport.testsuites.XMLChildren ){
22
fileWrite( url.reportpath & "/TEST-" & thisSuite.XMLAttributes.name & ".xml", toString( thisSuite ) );
23
}
24
}
25
// Writeout Results
26
writeoutput( results );
27
</cfscript>
Copied!

Ant

This build is our global build for running TestBox via ANT.
1
<?xml version="1.0"?>
2
<--<
3
This ANT build can be used to execute your tests with automation using our included runner.cfm.
4
You can executes directories, bundles and so much more. It can also produce JUnit reports using the
5
ANT junitreport tag. This is meant to be a template for you to spice up.
6
7
There are two targets you can use: run and run-junit
8
9
Execute the default 'run' target
10
ant -f test.xml
11
OR
12
ant -f test.xml run
13
14
Execute the 'run-junit' target
15
ant -f test.xml run-junit
16
17
PLEASE NOTE THAT YOU MUST ALTER THE RUNNER'S URL ACCORDING TO YOUR ENVIRONMENT.
18
-->
19
<project name="testbox-ant-runner" default="run" basedir=".">
20
21
<-- <THE URL TO THE RUNNER, PLEASE CHANGE ACCORDINGLY-->
22
<property name="url.runner" value="http://cf10cboxdev.jfetmac/coldbox/ApplicationTemplates/Advanced/tests/runner.cfm?"/>
23
<-- <FILL OUT THE BUNDLES TO TEST, CAN BE A LIST OF CFC PATHS -->
24
<property name="test.bundles" value="" />
25
<-- <FILL OUT THE DIRECTORY MAPPING TO TEST -->
26
<property name="test.directory" value="test.specs" />
27
<-- <FILL OUT IF YOU WANT THE DIRECTORY RUNNER TO RECURSE OR NOT -->
28
<property name="test.recurse" value="true" />
29
<-- <FILL OUT THE LABELS YOU WANT TO APPLY TO THE TESTS -->
30
<property name="test.labels" value="" />
31
<-- <FILL OUT THE TEST REPORTER YOU WANT, AVAILABLE REPORTERS ARE: ANTJunit, Codexwiki, console, dot, doc, json, junit, min, raw, simple, tap, text, xml -->
32
<property name="test.reporter" value="simple" />
33
<-- <FILL OUT WHERE REPORTING RESULTS ARE STORED -->
34
<property name="report.dir" value="${basedir}/results" />
35
<property name="junitreport.dir" value="${report.dir}/junitreport" />
36
37
<target name="init" description="Init the tests">
38
<mkdir dir="${junitreport.dir}" />
39
<tstamp prefix="start">
40
<format property="TODAY" pattern="MM-dd-YYYY hh:mm:ss aa"/>
41
</tstamp>
42
<concat destfile="${report.dir}/latestrun.log">Tests ran at ${start.TODAY}</concat>
43
</target>
44
45
<target name="run" depends="init" description="Run our tests and produce awesome results">
46
47
<-- <Directory Runner
48
Executes recursively all tests in the passed directory and stores the results in the
49
'dest' param. So if you want to rename the file, do so here.
50
51
Available params for directory runner:
52
- Reporter
53
- Directory
54
- Recurse
55
- Labels
56
-->
57
<get dest="${report.dir}/results.html"
58
src="${url.runner}&directory=${test.directory}&recurse=${test.recurse}&reporter=${test.reporter}&labels=${test.labels}"
59
verbose="true"/>
60
61
<-- <Bundles Runner
62
You can also run tests for specific bundles by using the runner with the bundles params
63
64
Available params for runner:
65
- Reporter
66
- Bundles
67
- Labels
68
69
<get dest="${report.dir}/results.html"
70
src="${url.runner}&bundles=${test.bundles}&reporter=${test.reporter}&labels=${test.labels}"
71
verbose="true"/>
72
-->
73
74
</target>
75
76
<target name="run-junit" depends="init" description="Run our tests and produce ANT JUnit reports">
77
78
<-- <Directory Runner
79
Executes recursively all tests in the passed directory and stores the results in the
80
'dest' param. So if you want to rename the file, do so here.
81
82
Available params for directory runner:
83
- Reporter = ANTJunit fixed
84
- Directory
85
- Recurse
86
- Labels
87
- ReportPath : The path where reports will be stored, by default it is the ${report.dir} directory.
88
-->
89
<get dest="${report.dir}/results.xml"
90
src="${url.runner}&directory=${test.directory}&recurse=${test.recurse}&reporter=ANTJunit&labels=${test.labels}&reportPath=${report.dir}"
91
verbose="true"/>
92
93
<-- <Bundles Runner
94
You can also run tests for specific bundles by using the runner with the bundles params
95
96
Available params for runner:
97
- Reporter
98
- Bundles
99
- Labels
100
101
<get dest="${report.dir}/results.html"
102
src="${url.runner}&bundles=${test.bundles}&reporter=${test.reporter}&labels=${test.labels}"
103
verbose="true"/>
104
-->
105
106
<-- <Create fancy junit reports -->
107
<junitreport todir="${junitreport.dir}">
108
<fileset dir="${report.dir}">
109
<include name="TEST-*.xml"/>
110
</fileset>
111
<report format="frames" todir="${junitreport.dir}">
112
<param name="TITLE" expression="My Awesome TestBox Results"/>
113
</report>
114
</junitreport>
115
116
</target>
117
118
</project>
Copied!
Copy link
Edit on GitHub
Contents
Ant