notexOPENOverview
Notex/Languages/Code Review: Tests with Mocks and Stubs
05.27LESSON 27 OF 29 · 1 MIN READ

Code Review: Tests with Mocks and Stubs

Always free to read
  • Make sure your code interacts with other components via abstractions. They make code easier to understand and easier to test.

  • Prefer function-field stubs over switch-statement stubs when the same method needs different behavior across test cases.

  • Stubs are useful for testing, but verify that usign one is helping you test your production code, not the stub itself.

  • Use httptest to validate that the HTTP clients in your code are both sending and receiving data correctly.

  • Separate unit tests from integration test via tags or environment variables.

Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K