[SalesForce] Debugging Apex Code using Checkpoints

I currently run the Apex code using Anony exec/test class and Check the system debug logs or write system.debug to check the logs. But I feel the need to check line by line debugging of the code, with a watch window showing the values that variable processes.

In short, I am looking for the internal detail of my code when developing. Something similar to the "Watch Window" in C. Is it possible?

I have read developer console section, for Checkpoint, but wasn't clear on its use.

Has any one used "Set and View Checkpoints in Apex Code:" option from DeveloperConsole
and can share how to use it.

Best Answer

Salesforce do not allow true breakpoints and single stepping as this puts too much load on their servers because instead of a transaction being short lived a debugging session can leave a transaction open for many minutes. The lack of these normal debugging mechanisms makes developing logic of any complexity more challenging in Apex than in many other languages.

The nearest approximation offered - the Checkpoint mechanism (AKA "Simulated Breakpoints") - requires you to decide up front where in your code you want to examine the state so that the tooling can take a copy of the state and then move on, thus avoiding significant delay in the transaction. So instead of picking a few items of data to output (as you do by adding a System.debug call) you get a more comprehensive view of the data (at the nominated point(s) in your code).

I've only tried to use this when it was first released and didn't find it very helpful then so still just use System.debug. Others may be able to report more positive experiences and advice on how to use Checkpoints effectively in their answers here...

PS

See Force.com IDE Debugger. New feature? for snippets about full debugging capability (though no definite release date).

Related Topic