Using request.debug()

What is request.debug()?

One of my favorite features of MXUnit is the debug() function, described here. 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:

request.debug() example

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?  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

Can I turn it on in those contexts?

Yes.  Here's how:

Enabling request.debug in the HTML Runner Context
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.