Mocks vs stubs vs spies, dependency injection for testing, jest.mock/unittest.mock/gomock, and when NOT to mock. Use when the user needs to isolate dependencies in tests, asks about mocking external services, or has tests tightly coupled to implementation details.
Receba novas skills de DevOps e Infra toda segunda
1 email curto, só com as skills novas de DevOps e Infra. 4 minutos de leitura, sem spam, cancela com 1 clique.
Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.
Ler descrição completaRecolher descrição
Mocking Strategies
Mocking isolates the code under test from its dependencies. Done right, mocks make tests fast and focused. Done wrong, they create brittle tests coupled to implementation details.
When to Use
User needs to test code that calls external APIs or databases
User asks about mocks, stubs, spies, or fakes
Tests are slow because they hit real services
User wants to test error paths that are hard to trigger naturally
Tests are brittle and break on internal refactors
#
[Description truncada. Veja o README completo no GitHub.]