The easiest way to debug is by forcing bugs into the smallest area possible. This can be achieved by incremental development.
By using TDD (which you already are, right?), incremental development is already being put into action. By testing small bits of code as they are created, the area in which a new bug could have occurred is greatly limited.
Combining this knowledge with the following strategies should, in theory, make debugging a breeze, as only this small area needs to be searched.
## Error Output Analysis
When an issue arises that causes a test to fail or the system to crash, an error message is always printed along with it. These error messages are often times extremely useful (at least in Java; not everything is just a segfault in this language) and should be read carefully.
Generally speaking, the error message will give a rough location of where the error occurred, at worst, and the exact location, at best. For most simple issues, it will state exactly what went wrong, as shown below.
<palign="center">
...
...
@@ -30,8 +33,9 @@ This is a rather simple example, however, the basics remain the same for all iss
## Confirming your inputs
If a source to your problem cannot be found, confirm that your inputs will, in fact, produce the expected result, assuming the code is working as intended. Sometimes the "issue" cannot be found because there was no issue with the actual code in the first place. Rather, it is the test that is incorrect.
## Use the Debugger
Often times it is easier to solve an issue by using the Debugger.
## Walk through the code with a Debugger
Often times it is easier to solve an issue by using a debugger. To learn how to use the Intellij debugger, follow the link below.