How to use the Debugger in VS Code for Java!

Debugging is the process of solving issues/errors that exist in your code. VS CODE’s built-in debugger helps accelerate your edit, compile and debug loop.

Debugging in VS CODE can be done by the following steps:

  1. Search for the “Beaker” shaped Test button which is located on the left side panel of your workspace. Click on it.

  2. A new Java Test Runner Window is now open. Select your project package.

  3. Choose the respective Test Function that you would want to debug from the drop-down.

  4. A new file opens describing the various Test cases for your Test function. There are 2 options visible there

    Run Test - This will evaluate the logic of your code against the existing test cases.

    Debug Test - You can add a breakpoint in your java file at any point, to debug an issue.

  5. Left-click on Debug test, to debug your code.

  6. You can add many breakpoints to your code for debugging. If you want to stop the debugger then you can click on the Cancel button at the bottom right-hand side.

  7. To go-ahead to the next breakpoint, click on the resume button.

  8. In the end, a Java Test report is generated to verify that your test has passed or not.