View Source

h1. What is request.debug()?

One of my favorite features of MXUnit is the debug() function, [described here|View Debug Output]. As you're developing, you might find yourself wishing you had a debug() function to use in the components you're building, not just in the unit tests themselves.

You can\! MXUnit will create a function called request.debug() that is hooked into the same glob of debug output as the debug() function you use in your tests. Thus, in any component you're trying to test (or its dependencies, for that matter), if you're running the code from within MXUnit, request.debug() will be available.

It would look something like this:

{code:title=request.debug() example}
<cfcomponent name="MyDAO">
<cffunction name="getSomeData">
<cfset var myQuery = "">
<cfquery name="myQuery">
select foo from bar

<cfset request.debug(myQuery)>

h1. Is it turned on by default?

It is turned on by default ONLY when tests are run from within the Eclipse plugin. Tests run within the browser and a DirectoryTestSuite (this includes tests executed with ANT) will not have this function available by default. The reason is simple: we believe that it's a bad thing to commit your changes to source control with stray request.debug() calls left in there. We believe most people run their tests from within Eclipse while developing, but entire suites of tests should also be run in the browser, or via ANT, in a scheduled process. Otherwise, what's the point of having tests if they're not running at least once a day?&nbsp; By turning them off in non-Eclipse contexts, you're more likely to catch the cases where you forget to remove the request.debug() calls when they're no longer helping you write your code

h1. Can I turn it on in those contexts?

Yes.&nbsp; Here's how:

{code:title=Enabling request.debug in the HTML Runner Context}
<cffunction name="testRequestDotDebug_WillPassInBothPluginAndWeb">
<cfset createRequestScopeDebug()>
<cfset obj = createObject("component","SomeObject")>
<cfset debug("before the object calls request.debug")>
<cfset obj.thisWillOnlyWorkInThePlugin()><!--- only work in plugin.... unless we explictly enable it in the test!!! --->
<cfset debug("after a function that called request.debug")>
<cfset stopRequestScopeDebug()>