Stop Using Mocks In Unit Tests

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 11

  • @j3bb9z
    @j3bb9z 6 หลายเดือนก่อน +4

    You're describing e2e tests. They're easier to write but it's harder to test all the paths and the tests take more time. I prefer to use both e2e tests for main paths and unit tests with mocks to ensure there's high code coverage.

    • @LeutnantJoker
      @LeutnantJoker 4 หลายเดือนก่อน +1

      Code Coverage has no value. It's the most garbage metric on the planet. I can write you a test suite that achieves 100% coverage and doesn't test a single thing. Stop using that metric, it doesn't mean anything, anything at all.

    • @j3bb9z
      @j3bb9z 4 หลายเดือนก่อน +1

      @@LeutnantJoker I disagree. There is a code coverage metric named "beaches". It's one of the most valuable metric when it comes to testing. Keeping that metric at high percentage ensures every condition is tested. Having 100% lines coverage may not be a reasonable goal, but having high percentage of branch coverage definitely is.

    • @LeutnantJoker
      @LeutnantJoker หลายเดือนก่อน

      @@j3bb9z I can achieved 100% branch coverage without testing a single thing. The metric is BS

    • @j3bb9z
      @j3bb9z หลายเดือนก่อน

      @@LeutnantJoker You don't know what you're talking about. But I'm not going to waste my time convincing you. Do as you wish.

  • @ZanarkandStarplayer
    @ZanarkandStarplayer ปีที่แล้ว +1

    I learned a lot! Thanks for the video :)

    • @kikisbytes
      @kikisbytes  ปีที่แล้ว

      hey that's awesome! I'm so glad you that you were able to find it useful!.

  • @dimashtef7077
    @dimashtef7077 8 หลายเดือนก่อน +1

    In big apps unit tests are also a way to track changes, if youve changes something important test should highlight it

    • @kikisbytes
      @kikisbytes  8 หลายเดือนก่อน

      agreed the best tool to protect against regression

  • @kam1234554321
    @kam1234554321 หลายเดือนก่อน

    If only my teammates could understand. I'm trying to explain the same to them and it looks like talking to a wall. I even had 1 person saying (btw. he has 7y of exp) "unit tests are more important than integration tests". Dude, if your graphics card, cpu, ram work separately - it doesn't mean they will work properly joined together. Then another person keeps creating mocks in integration tests or keeps verifying that serviceA was called x times in a unit test. I tried to explain to them multiple times that changing the implementation shouldn't break a unit test because we can't fix/improve the code and we should be able to verify that it still behaves the same. The answer always was "yeah, then in this case you should fix the code" and the entire team is like "yeah, I agree". Man, I'm already sending my resume and can't wait to change my job... I'm just tired of that shit... I feel like I'm working with interns but these people are almost 10 years in the business...

  • @doyouwantsli9680
    @doyouwantsli9680 10 หลายเดือนก่อน

    Yep, integration tests are much more important.