3 ms·
Exactly. As you try to write tests for things that break you may find that it's actually really hard to write tests. You need to initialize a database, or your
by ZainRiz 11y ago
Exactly. As you try to write tests for things that break you may find that it's actually really hard to write tests. You need to initialize a database, or your code depends on X, Y, Z, and they all need to be setup.
This is an opportunity for refactoring.
Try to refactor just the code that's affected by the bug in a way that lets you inject any dependencies that it had. You can then inject Mock, Fakes, etc, and validate that the code your refactored out works as expected.
You've now added tests and refactored your code to be more maintainable. A 2 for 1 punch.