Ask HN: Best resources to learn code testing

6 points by deanmoriarty ↗ HN
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:

- How to structure production code so that it’s testable

- How to effectively deal with dependency injection for testing

- The surface area and granularity of unit tests (what behavior should be tested vs not)

- When to use mocks/stubs/fakes

What are the best resources to fix my gaps? Open to books, courses, videos, etc.

3 comments

[ 2.0 ms ] story [ 28.6 ms ] thread
Depends on your language for ressources and what you are looking for.

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.

Integration tests are here to ensure your app/module will work fine once deployed.

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.

What I mean, I can't believe, how it is possible :)

I have hear about TDD for about 10 years. Thinking, it is obvious thing. Thinking, everybody learn it now from first steps.

Sorry for so many words, now answer.

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.

Good luck!