CS 61B Part 0.5 Java Debugging&Testing
prev: [[Basic_Java]]
next: [[61B_Part_1_Java]]
Breakpoints
previous debugging experience (Print statements):
- They require you to modify your code (to add print statements).
- They require you to explicitly state what you want to know (since you have to say precisely what you want to print).
- 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.
clickdebugging, 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 asstep into, except the step that included in a function(step over the function)
-step out: whenstep intogo into the function,step outcan 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.
JUnit test
1 |
|
All tests must be non-static.
Run the test and you will see the error:
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
