prev: [[Basic_Java]]
next: [[61B_Part_1_Java]]

Breakpoints

previous debugging experience (Print statements):

  1. They require you to modify your code (to add print statements).
  2. They require you to explicitly state what you want to know (since you have to say precisely what you want to print).
  3. And they provide their results in a format that can be hard to read, since it’s just a big blob of text in the execution window.
    click the line, and now, we have breakpoint.
    breakpoint.png (2860×1610) (datastructur.es)
    click debugging , and the currently highlighted line is the line that is about to execute, not the line that has just executed.
     you should see that the program has paused at the line at which you set a breakpoint, and you should also see a list of all the variables at the bottom
     - step into: advancing the items into one step
     - step over: the same as step into, except the step that included in a function(step over the function)
     - step out: when step into go into the function, step out can step the function and return to the parent function
     - resume: run the code until hitting the code one more time

conditional breakpoint

rightclick the line, and you can set up the conditional breakpoint.
conditional_breakpoint.png (508×291) (datastructur.es)

JUnit test

1
2
3
4
5
@Test
public void testMethod(){
assertEquals(<expected>, <actual>);
assertTrue(<condition1>, ...);
}

All tests must be non-static.
Run the test and you will see the error:
default_renderer.png (1169×426) (datastructur.es)