Using fake objects in automated tests

Поділитися
Вставка
  • Опубліковано 16 лис 2024

КОМЕНТАРІ • 19

  • @kauffinger
    @kauffinger Рік тому

    Right now I am deep in mocking hell, where everything was mocked - whenever I change any code of the services, at least 1 test breaks, even if no behaviour was changed. This makes so much more sense than my way - i just make the mock partial, ignore missing calls and mock the return values of anything that is needed.
    Still makes the code ugly and needs fiddling until it works.
    Thanks for the video!

    •  Рік тому +1

      Thanks for watching and I’m glad I could be of help!

  • @stevebauman
    @stevebauman Рік тому +4

    While I definitely like fakes and I think they are a great way to test, I will personally never default to them, and I think there has to be justification for them. They all come with additional baggage that mocking simply doesn't have:
    1. Additional time to setup, and you have to now have to worry about designing your fakes assertion API
    2. Lots of additional boilerplate for anything you would initially want to mock
    3. Fakes now need their own tests, as they now encompass additional logic to make assertions, which could break, and may have their own bugs
    4. Test code is now intertwined with application code

    •  Рік тому +2

      Steve! Thanks for chiming in dude.
      I think the setup time is very minimal in regards to the benefits - setting up an interface and a different implementation is something you’re only going to do once.
      IME the annoyances I had with mocks throughout my life totally justify spending time with fakes. Obviously that’s very different with e.g library code where mocking happens frequently.
      You can easily remove coupling with the testing framework by having assertions within the test (if that’s what you meant, otherwise if it’s the in memory implementation being a test implemented intertwined with app code, I disagree). I just can’t see the benefits of mocks these days if fakes are an option.

    • @stevebauman
      @stevebauman Рік тому

      @ Fair enough!
      Great video by the way and thanks for the reply! 🙏

  • @erfansabouri7362
    @erfansabouri7362 Рік тому

    Thanks. You lighten me up.

    •  Рік тому +1

      Glad I could be of help :-)

  • @oleksiiberestniev5432
    @oleksiiberestniev5432 Рік тому +1

    many thanks

    •  Рік тому

      Welcome!!

  • @chhirag
    @chhirag Рік тому

    Thanks for the video, very well explained.

    •  Рік тому

      Glad it was helpful!

  • @metaphoricallyspeaking
    @metaphoricallyspeaking Рік тому

    Awesome video Mateus 👏

    •  Рік тому

      Thanks buddy!

  • @Alguem387
    @Alguem387 Рік тому +1

    wait i though fake objects and mocking where the same thing

    •  Рік тому

      They’re both test doubles and serve the same purpose 👍

  • @user-bk1ts4th2h
    @user-bk1ts4th2h Рік тому

    nice videos ! , thank you , please can you make videos inside playlists

    •  Рік тому

      Thanks for the idea!

  •  Рік тому

    Nice english!

    •  Рік тому

      Valeu