Outputting test performance

First, it should be noted that CFUnit is not intended to be a performance tuning tool. There are other better ways of handling that.

However, it can sometimes be helpful to know which of your tests within a TestCase are running slowly. To do this, simply add the following code to your TestCase:

	...
	<cffunction name="setUp" returntype="void" access="package">
		<cfset REQUEST.timer_start = getTickcount()>
		<!--- Other Setup Code Here --->
	</cffunction>
		
	<cffunction name="tearDown" returntype="void" access="package">
		<!--- Other TearDown Code Here --->
		<cfset REQUEST.timer_end = getTickcount()>
		<cfset REQUEST.timer = REQUEST.timer_end - REQUEST.timer_start>
		<cftrace var="REQUEST.timer" text="#getString()#"></cftrace>
	</cffunction>
	...

You don't need anything else. Next time you run your tests scroll down to the CFML debug output. In the Trace Points you will see a number of lines like this one:


[20:30:44.220 X:\mywebroot\CFUnitExample\TestMyCFC.cfc @ line: 16]
[501 ms (1st trace)] - [REQUEST.timer = 70] testMethod(CFUnitExample.TestMyCFC)

"REQUEST.timer" equals how long, in milliseconds, each test took to run.