How to hunt a bug
Tests play a key role in hunting down a bug and ensuring it doesn’t come up again. To do that, you should follow a process.
Whenever a bug is discovered (by you or your team) or reported (by the user), you should write tests that reproduce it. These tests can be of different types. These are to ensure that the bug doesn’t come up again.
Now, run your tests and you should notice that tests are failing. Tests that cover wider ranges (such as system or integration tests) will tell you in what component of the application the bug is happening. Then, more granular tests (such as unit tests) will tell you in what class and ultimately in what method the bug is hiding.
By using a smart combination of both wide-range and granular tests, you will be able to hunt down the bug. Keep in mind that breakpoints will be great allies.
And that’s it! We are now armed with everything we need to enhance the quality of our application by leveraging software...