Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 2.42 KB

output-utilities.md

File metadata and controls

48 lines (33 loc) · 2.42 KB
icon
rectangle-terminal

Output Utilities

Tests Output Utilities

Sometimes you will need to produce output from your tests and you can do so elegantly via some functions we have provided that are available in your test bundles:

MethodComment
MethodComment
console()Send output to the system console
debug()Send output to the TestBox reporter debugger
clearDebugBuffer()Clear the debugger
print()Send output to the output buffer (could be browser or console depending on the runtime)
printLn()Same as print() but with a new line separator. (Ccould be browser or console depending on the runtime)

These are great little utilities that are needed to send output to several locations from within your tests.

{% hint style="success" %} Hint: Please note that the debug() method does NOT do deep copies by default. {% endhint %}

console( myResults );

debug( myData );
debug( myData, true );

debug( var=myData, top=5 );

print( "Running This Test with #params.toString()#" );
println( "Running This Test with #params.toString()#" );

Request Output Utilities

Sometimes you need to dump something that is in the CFC you are testing or maybe an asynchronous test. The aforementioned methods are only accessible from your test bundle, so getting to the TestBox output utilities is not easy.

Since version 4.0 we have implemented the testing utilities into the request scope as request.testbox. Which will give you access to all the same output utilities:

Method Comment
console() Send output to the console
debug() Send output to the TestBox reporter debugger
clearDebugBuffer() Clear the debugger
print() Send output to the ColdFusion output buffer
printLn() Same as print() but adding a <br> separator
request.testbox.console( "I am here" )
request.testbox.debug( "why is this not running" )