After
Two common challenges—multithreading and database interaction—are tough-enough topics on their own. Often many of your defects will come from code in these areas.
In general, you want to adhere to the following strategy for testing these more-difficult scenarios:
-
Separate concerns. Keep application logic apart from threading, database, or other dependencies causing you a problem. Isolate dependent code so it’s not rampant throughout your codebase.
-
Use mocks to break dependencies of unit tests on slow or volatile code.
-
Write integration tests where needed, but keep them simple and focused.
Next up: you’re almost ready to graduate. So far, you’ve focused on heads-down unit testing on your development machine. For the final chapter, you’ll ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access