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.
Loading...
Related Quiz
- In which collaboration tool can developers create and manage branches for implementing new features or fixing bugs?
- Angular follows the _______ architecture for building applications.
- What is the purpose of a data structure?
- What does SQL stand for?
- NoSQL databases are often used in scenarios where _______.