• Ethan@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    How does dependency injection have anything to do with writing tests? I write tests by writing a test function that executes the code I want to test…

    • DeprecatedCompatV2@programming.dev
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      1 year ago

      I mean unit tests. I work on Spring Boot apps where there are distinct layers (controller -> service -> persistence), and you generally inject mocks into your object to isolate tests to the specific code you want under test. One benefit of this approach is that it’s pretty easy to get 90% coverage.