3

Is it really possible to use the dev console & checkpoints to effectively debug code via unit tests? It seems like it should be possible, but I've never gotten it to really work for me.

Here's my biggest problem: I have a class & a test class. The test class contains several test methods, all of which test basically the same code in the main class. Each tests a different scenario. Pretty common.

I set a checkpoint, on a line of code that should be run (at least once) as part of every test method. Then I run the test class.

Result: I get one and only one checkpoint result. IT does not indicate anywhere (AFAIK) which test method produced it.

Expected result (or desired result if this is gonna be workable at all): one checkpoint result per test method (or per execution of that line per test method), clearly indicating which test method produced it.

Is there any way to get to there from here?

(FWIW, there have been several other questions about this, but none that I've seen has addressed this.)

Thanks!

1 Answer 1

2

Only one checkpoint per line (up to 5 lines) can be gathered per apex execution. For example, if you put the checkpoint location in a loop, you will only get one and only one checkpoint for that line. You can modify the "iteration" value of the checkpoint, which will wait until the nth time that line has been executed before gathering the heap. There is a line in the apex log for when the checkpoint is recorded.

In your example, you can see what test method the checkpoint is in by searching for "HEAPDUMP" (or "HEAP_DUMP") in the apex log, then look at the "Stack" panel to see what test method your are in. If you want to look at the setup for another test method, change the iteration. I don't know if test methods are ran in order but, if they are, an iteration of 1 would be the first test, 2 would be the second, and so on.

1
  • Thanks, Thomas. Very helpful. Although I think this would place things squarely in "no, it can't be used to effectively debug unit tests" territory, which is unfortunate.
    – mscholtz
    Commented Aug 27, 2014 at 5:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .