helpers icon indicating copy to clipboard operation
helpers copied to clipboard

Document our guidelines for mocking

Open gpsaggese opened this issue 7 months ago • 1 comments

          Ugh. There is so much mocking that at best we test only what you already know it works, at worst we don't really test anything.

Our rule for mocking is to mock only the external services (in this case we should mock the interaction with GH)

Can we improve helpers_root/docs/coding/all.write_unit_tests.how_to_guide.md explaining these, making examples and so on?

You can work with @heanhsok on this

Originally posted by @gpsaggese in https://github.com/causify-ai/helpers/pull/649#discussion_r2072684173

gpsaggese avatar May 04 '25 18:05 gpsaggese

The code has pretty much no standard so everybody mocks in different ways.

  1. I don't like decorators, the context manager approach makes the code too nested
  2. Clear rules for mocking only the external services
  3. Too much dependency on how things are done makes the unit tests brittle
  4. Too much mocking means we don't test anything
  5. We should test things as close as "production" as possible (when we mock too much we end up testing the mocking and not the actual system)

gpsaggese avatar Jun 20 '25 13:06 gpsaggese