3

I am new to VS Code, I have read up on it. I can write APEX very well but only in the developer console. I am used to System.Debug Logs. I see that in VS Code you can put in Breakpoints versus debug statements. For all of the examples I have seen it seems like you must debug your test classes versus your actual Apex Classes and Triggers.

My Question is can you just debug your Classes and Triggers or do you have to have a Test Class First?

What I tried: https://trailhead.salesforce.com/en/content/learn/projects/find-and-fix-bugs-with-apex-replay-debugger/apex-replay-debugger-debug-your-code

I placed BreakPoints into my code. Opened the debug Log Launched the Apex Replay Debugger It goes to the first Line once i hit F5 it just stops.

1 Answer 1

3

My Question is can you just debug your Classes and Triggers or do you have to have a Test Class First?

You will need to have a Test Class and execute it before you can debug your underlying Apex classes using Apex Replay Debugger.

The way it works is that once you run a Test Class, logs are generated. And then you use those logs to debug your classes. So your debugger is necessarily running on the logs. And during the execution, whenever the debugger encounters a breakpoint, it pauses there.

2
  • Thanks.... This seems like a terrible way to Program though. Its almost as if you need to write yours test class before you can write the actual code.....
    – CodeMonger
    Dec 5, 2019 at 13:11
  • Well, not really. Remember Apex classes are not executable classes as you would see say a Java class with main method. So to necessarily execute the class if not running within the context it is supposed to run, you will need a test class. You can think this of a test-drive development
    – Jayant Das
    Dec 5, 2019 at 14:46

You must log in to answer this question.

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