Skip to content

Instantly share code, notes, and snippets.

@d1rtym0nk3y
Last active December 11, 2015 11:28
Show Gist options
  • Save d1rtym0nk3y/4593633 to your computer and use it in GitHub Desktop.
Save d1rtym0nk3y/4593633 to your computer and use it in GitHub Desktop.
<!---
example of using DirectoryTestSuite to run mxunit tests
assumes your tests are located at /tests/unit, or there is a mapping to that location
and that tests are organised into modules under this directory
--->
<cfif not structkeyexists(url, "module")>
<cfdirectory action="list" directory="#expandPath('.')#" name="dir" >
<cfoutput>
<h3>Choose tests to run</h3>
<ul>
<li><a href="?module=all">All Tests</a></li>
<cfloop query="dir">
<cfif dir.type is "dir">
<li><a href="?module=#dir.name#">#dir.name#</a></li>
</cfif>
</cfloop>
</ul>
</cfoutput>
<cfelse>
<cfset path = expandPath('.') />
<cfset cfcpath = "tests.unit" />
<cfif url.module is not "all">
<cfset path = listappend(path, url.module, "/") />
<cfset cfcpath = listappend(cfcpath, url.module, ".") />
</cfif>
<cfinvoke component="mxunit.runner.DirectoryTestSuite"
method="run"
directory="#path#"
componentPath="#cfcpath#"
recurse="true"
returnvariable="results" />
<cfoutput> #results.getResultsOutput()# </cfoutput>
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment