I have more than a decade of experience in software development (now team lead at a FAANG, working on higher level systems) and I embarrassingly realize I still do not know how to write good tests and testable code. Specifically:<p>- How to structure production code so that it’s testable<p>- How to effectively deal with dependency injection for testing<p>- The surface area and granularity of unit tests (what behavior should be tested vs not)<p>- When to use mocks/stubs/fakes<p>What are the best resources to fix my gaps? Open to books, courses, videos, etc.
This book was really helpful for me. It broke down how to structure tests, what results in brittle tests, what to avoid to keep tests maintainable. I believe it answers most of your questions. Software Engineering at Google, Chapters 11-14 Testing: <a href="https://www.oreilly.com/library/view/software-engineering-at/9781492082781/ch11.html" rel="nofollow noreferrer">https://www.oreilly.com/library/view/software-engineering-at...</a>
Depends on your language for ressources and what you are looking for.<p>Unit testing is supposed to test the code alone with no external dependecy (db, API,...), that's when you need mocks/stubs. Unit testing helps a lot with refactoring and code quality.<p>Integration tests are here to ensure your app/module will work fine once deployed.<p>I don't have any particular recommendation for a site or else, I think the best is to do some research, make up your own mind and see what suits best your case/needs.
Sorry, I read your previous comments, and you are now really mystery person for me.<p>What I mean, I can't believe, how it is possible :)<p>I have hear about TDD for about 10 years. Thinking, it is obvious thing. Thinking, everybody learn it now from first steps.<p>Sorry for so many words, now answer.<p>Just google "best software testing books", QA resources (yes, just lear QA). For example known name Copeland; also good Myers; other big figures, Jorgensen, Dorothy Graham.<p>Good luck!