top of page
image 82.png

Run/Debug configuration using breakpoints

In this section, we will learn about:

  • Debugging

  • Debugging using breakpoints in IntelliJ


Debugging is the process of detecting and removing existing and potential errors (also called 'bugs') in a software code.

Suppose a tester is unit testing the software and finds some errors then he will ask the developer to resolve the error in the particular section defined by the tester. So, the developer can find the bug or error with the help of a debugger.

A mark (breakpoints) is made on the line until you need to debug (where the potential error can be). Once debugging is done, it will provide you with all sets of work that are being done on that line of code. (That being small variables used, what values are stored, and everything). So it will help to analyze the code easily and fix errors.

Debugging using breakpoints in IntelliJ

1) To debug your code using breakpoints in IntelliJ, first, you need to set a breakpoint.

  • Choose the line where you want to put a breakpoint. And then on the left side of the code window, you will find line numbers written. Click on just the right of the line number and you will see a red circle. That red circle is a breakpoint.

  • You can set different breakpoints in different places.

  • We will set a breakpoint in “YogaMemberController” in the method which adds the user.

2) And then you need to use debug your application using either “Shift+F9” or going to “Run -> Debug ‘application_name’” in the navigation bar.

3) Now your application will start running in debug mode. And you need to open your swagger and hit the add user API.

You will find that your API is not returning any response and showing “loading” after hitting the execute button. This is because it is debugging.

image 87.png

Fig: Showing a loading screen after hitting the API.

4) Now open your IntelliJ, and you will find a log that shows everything used till the breakpoint. Here, you can find all variables used and their values, etc.

image 88.png

Fig: Debug status.

5) In the variable window, you can check the value of the variable in the flow. Here, we are passing “Chris” as the member name, “string”, etc. as “memberReqDTO”, which can be seen both in the code window and variable window. Then it is converted into YogaMember and passed to service. So, we can check if there is any breakage in any part.

6) For checking the next line, we need to either press F8 or the “step over” button in the debugger window (2nd right to “console”).

7) For entering into the method in the line, we need to press either F7 or the “step into” button next to step over. Here, it will take us to the service class.

8) Now, finally, we need to hit the stop button on the left (red square) to stop debugging and this will resume the execution of our API.

  • We can also set a condition on the debugger line by right-clicking on the red circle. We can set any condition like if the value of x = 3, then only debug.

  • We can also evaluate any expression by providing our data then and pressing “Ctrl+Alt+F8”. Alternatively, we can also hold Alt and click the selection. Or we can do so by clicking on the 2nd last button from the right in the debugger window.

bottom of page