-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-list.cfm
51 lines (44 loc) · 1.54 KB
/
test-list.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<cfscript>
testsDir = expandPath('/your/project/tests');
componentPath = 'your.project.tests';
files = createObject('mxunit.runner.DirectoryTestSuite').getTests(
directory=testsDir
, componentPath=componentPath
, recurse=true
, excludes="/Test.*$,^_assets/"
, precompile=false
);
// the results to return (we use a hashed map, so the tests are run in order)
results = createObject("java", "java.util.LinkedHashMap").init();
/*
* When generating results in batch, we only need the test suites, not the individual
* tests. For large code bases, this will speed up the request.
*/
if( structKeyExists(url, "batch") && isBoolean(url.batch) && url.batch ){
arrayEach(files, function (file, idx){
results[file] = [];
});
/*
* Since we are running each test individually, we need to return all the tests
* inside each test suite.
*/
} else {
suite = createObject('mxunit.framework.TestSuite');
// add each suite to the output
for (i = 1; i <= arrayLen(files); i++){
suite.addAll(files[i]);
}
tests = suite.suites();
// loop through the tests and get the test methods
iterator = tests.keySet().iterator();
while( iterator.hasNext() ){
suiteName = iterator.next();
suiteMethods = tests.get(suiteName).methods;
// sort methods alphabetically
arraySort(suiteMethods, 'textnocase', 'asc');
results[suiteName] = suiteMethods;
}
}
</cfscript>
<cfsetting showdebugoutput="false" />
<cfcontent reset="true" type="application/json; charset=UTF-8" /><cfoutput>#serializeJson(results)#</cfoutput><cfabort/>