With all my real world experience getting dumped, I never thought it could ever be a good thing. But in programming, getting dumped, more specifically, dumping variables, is immensely useful when debugging. I use it all the time when writing code.

But having lately been playing more and more with unit testing, specifically using MXUnit in Eclipse, debugging errors through unit testing seemed a bit more problematic.  I could put dumps in my CFCs but that output would never make it to my test case results. How was I expected to debug that way.

Then I had an idea. Stop me if you heard this one.  Instead of using “writeDump”, I raised an error. I used the throw statement. For the error type I put the name of the variable. For the message I put the value of the variable:  For instance, I put:

throw(message=userID, type=”User ID”);

When I run my unit test in Eclipse in my results I see “User ID: 84756”. Voila!  One caveat  however, and it is a big one, it only works with scalar values.  Figuring out how to dump structures and arrays will be my next task.

Always learning….always growing.