I know that I can get a cfdump of any variable from within my test
method using the debug() function, but sometimes I want to put a
cfdump inside the actual method that I'm testing. I know, with true
TDD there would be no need for this, but I am often refactoring old
code and end up with some methods that are pretty complex. Before I
started using the plugin to run my tests I'd just stick a cfdump +
cfabort in my method, run the app in a browser and see my dump output.
If I try to do this and run a test using the plugin I cannot see the
actual output of the cfdump.
My workaround thus far is to change the actual method that I'm
testing, return whatever it is I want to dump from the method, and
then use debug() on that returned value in my test method. But I
really don't like doing that.
Does anyone have any suggestions of how to do this more easily? If
not, is this something that could be achieved through changes to the
plugin code?
Thanks,
Bob
--
Bob Silverberg
www.silverwareconsulting.com
You, dear sir, are some type of alien.
=]
Seriously tho: I've had those late-nite seshes where I stick that
<cfabort> in there and then fall asleep (monitor bright as day, even).
That's a real bitch, when you wake-up, and forgot you stuck that
randomness there, neh? You're all like "why the hell is this thing
just outputting blankness?". And good luck sorting out the "real"
cfabort amongst the commented-out ones, right?
Yeah, it happened to me once. I was pretty pissed, so it didn't
happen more than once or twice more. :-)).
Even having lived through that-- or, those, experiences, I'm in favor
of an un-pure debug type deal.
But I'm "dirty". =]
--
I find it ironic how far I will go, to be lazy.
server.debug = debug;
variables.transactionService = coldSpring.getBean('transactionService');
variables.transactionService.debugarray = this.debugarray;
lets me use server.debug() within my TransactionService component.
It's a total hack job, but seems to work. On Railo at least.
I usually have a dumpvar() in any complex component, that I generally
use to dump>abort from within cfscript and whatnot. If I didn't want
to have errors about missing debug when running outside the harness, I
could stick the debug in there, with a check for existence. That
would be more pure and less dangerous... but I don't mind living on
the edge.
Especially if I get selenium rocking on the dev server. Then I think
I'd actually prefer an error, as I really don't like "forgetting"
where I've got debug() or log() type stuff.
Eh...
The other thought I had was that cfdump content must be stored
somewhere, even if it's not "output"... I wonder if that content is
accessible from the request object somehow? If so, it's probably done
different with each CF engine, but grabbing that content and adding it
to the debug content would be pretty cool, maybe.
Eh.
Random ideas. =]
:denny
--
The existence of law is one thing; its merit or demerit is another.
J. L. Austin
But you can use <cfdump var="#whatever#" output="console"/> and have
debug output appear in your terminal console. You do start CF from a
console right? All the CF team tell folks to do this in development
whenever they give presentations at conferences :)
Seriously tho', <cflog ... log="console" /> and <cfdump ...
output="console" /> are two very useful debugging tools when working
with CFC-based applications.
Assuming you don't want to use the incredible CF8 Eclipse debugger, of course...
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
Here is the test I was using to, um, test the idea (a test and a component):
http://coldfusion.pastebin.com/me07eb42
Check that out and if it doesn't work, I guess we chalk it up to a
difference between railo and adobe cf.
HIH!
:D
--
That whose existence is necessary must necessarily be one essence.
Avicenna
With the injection, it looks like we're only getting one level deep
into the object "chain", if you will (no objects created by that
object will have mxunitdebug injected).
I think that we're going to have to get "messy" to really make this as
useful as it should be.
"Messy" meaning I think we're going to have to tap one of those global
scopes-- request or server, probably -- to be able to add a call to
debug from anywhere down the chain (I know there's a gooder word for
"the chain", but I'm drawing a blank).
Instead of using server, I tried the request scope, and after changing
TestCase to store it's "debugArrayWrapper" in the request scope, I was
able to use request.debug() from an object a few levels down.
This made me happy, but I wonder-- well, basically about race
conditions. I don't know how easy it would be to really get this
working, um, in an organized manner, so to speak. Using the request
scope seems like bad form, but, well, it seems to work.
Perhaps some type of introspection/reflection would allow us to inject
into sub-objects, and sub-sub-objects, but it seems harder to control
that than using, say, the request or server scope.
Bah. My head isn't exactly into the problem, but I just wanted to put
these thoughts out there.
--
A special kind of beauty exists which is born in language, of
language, and for language.
Gaston Bachelard
On Mon, Dec 15, 2008 at 6:32 AM, Marc Esher wrote:
>
> All,
> If you're interested in seeing the automatic debug injection in
> action, here's what to do. this assumes you're familiar enough with
> subversion to get this all working.
...
I've got a little patch that seems to work like this:
if you set request.debug = this.debug in setUp(), you can do
request.debug(whatever) from any component accessed during the
request.
This is working pretty good for me (tested from within the eclipse
plugin, using Railo), as if I remove or comment out the setUp()
request.debug = this.debug line, I get errors wherever I'm still
calling request.debug.
I think a URL switch might be cleaner (thus defaulting to "off", as
well as negating the need to set request.debug in the test itself-- a
little redundancy for the forgetful ;]), and would allow for adding a
toggle to the eclipse plugin UI pretty easily, perhaps...
I feel that using this shortcut is one step closer to the dark side of
the force... I also feel that it's powerful enough to justify it's
[careful] use. [=
Seriously: this probably won't be how it's implemented, but after
having the power this last month or so... I want it.
Here's what seems to be working for me (patch format):
http://coldfusion.pastebin.com/m43115e4e
Not much there, which I like.
It's working for me, but may be horrendously flawed, and perhaps make
your hard-drive play jingle-bells, so, ya know. just say'n. =]
I'm down to try to URLize it and add something to the eclipse plugin
UI, if it's wanted (and this stuff doesn't look too ugly-- suggestions
welcome!).
:Denny
--
In order for the light to shine so brightly, the darkness must be present.
Francis Bacon