14
scout
325d

I used to hate writing tests, surprisingly now I’m kinda enjoying it this time.

Comments
  • 4
    Phase 1: Learning about the concept of testing
    Phase 2: Thinking everything must be tested and people who don't have 100% coverage or only develop in TDD are dumb
    Phase 3: Oof we lost control of our insanely complicated and bloated tests that need you to mock http contexts and a particular database vendor so we haven't used them for 5 years
    Phase 4: Let's just write useful, simple, maintainable unit tests for the important bits

    The trick is to not slip back into 3 when you thought you were in 4.
  • 0
  • 2
    *pounds tequila* Test in prod
  • 1
    Testing is hard when you don't write testable code. With time it gets fun because you get better at writing good code and then testing is fun :)
  • 0
    @Mishik90 even if you do dependency injection, focusing on unit testing will make you over abstract everything introducing unnecessary complexity and the 80% you are testing are mocks. I rather flip the pyramid and only emulate/mock external systems and focus on integration/end2end tests. That way you are actually testing the system and how is really behaves while covering a lot with a few cases.
    Only where there is complex business logic unit test. This prevents exploding the integration/e2e test cases. Besides the logic heavy units usually don't have a lot of external dependencies.
  • 1
    @hjk101 I do same, it's crucial to pick the right testing method for your case. If you have concrete logic you want to assure to be working in different scenarios then unit-testing is great. Everything has it's limitations and pros/cons.
Add Comment