You encounter a bug in your codebase. How would you use TDD principles to fix it and prevent similar issues in the future?

  • Fix the bug directly without writing tests
  • Ignore the bug and focus on adding new features
  • Write a failing test that reproduces the bug, fix the bug, and ensure the test passes
  • Write tests for unrelated features to cover more code paths
Using TDD to fix a bug involves writing a failing test that reproduces the issue, then fixing the bug to make the test pass. This ensures that the bug is addressed and helps prevent regressions by having a test in place.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *