Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Some strange stories about mocks.

The talk about my personal journey of using mocks in tests.

Why I personally don’t like them?

Why it’s kind of a hot topic in the dev communities?

  • Login to see the comments

  • Be the first to like this

Some strange stories about mocks.

  1. 1. Some strange stories about mocks And why we don’t like them?
  2. 2. Andrew Nashkolniy Matic Insurance
  3. 3. Story #1: The Prehistory
  4. 4. Story #2: Testing with mocks
  5. 5. With Mocks Pros: - Isolation.
  6. 6. With Mocks Pros: - Isolation. - Speed.
  7. 7. With Mocks Pros: - Isolation. - Speed. - Accuracy.
  8. 8. With Mocks Cons: - Avoided Contracts.
  9. 9. With Mocks Cons: - Avoided Contracts. - Rely on Integrations.
  10. 10. With Mocks Cons: - Avoided Contracts. - Rely on Integrations. - Hard Refactoring.
  11. 11. Story #3: Testing without mocks
  12. 12. Without Mocks Pros: - Refactoring.
  13. 13. Without Mocks Pros: - Refactoring. - Reliability.
  14. 14. Without Mocks Cons: - Longer runtime.
  15. 15. Without Mocks Cons: - Longer runtime. - Snowball effect.
  16. 16. Without Mocks Cons: - Longer runtime. - Snowball effect. - You still use mocks.
  17. 17. Story #4: Origins
  18. 18. Problems with mocks in Java: - Other classes side effects.
  19. 19. Problems with mocks in Ruby: - Weak input params checks. - No output params checks. - Other classes side effects.
  20. 20. Interfaces & Strong typing
  21. 21. Unacceptable problems: - Refactoring difficulties.
  22. 22. Unacceptable problems: - Refactoring difficulties. - Unreliable tests.
  23. 23. No mocks by default. But...
  24. 24. Good usage mocks: - Networking. - Streams. - IO operations. - Time. - System calls.
  25. 25. In the very end it really depends
  26. 26. Materials: - https://www.youtube.com/watch?v=KYG5C1CEkOk - https://medium.com/javascript-scene/mocking-is-a-code-smell-944a70 c90a6a - https://blog.codecentric.de/en/2018/03/mock-what-when-how - https://blog.carbonfive.com/2011/02/11/better-mocking-in-ruby - https://www.solutionsiq.com/resource/blog-post/to-mock-or-not-to-mock-is-that-even-a-question - https://clean-swift.com/to-mock-or-not-to-mock - https://blog.codecentric.de/en/2017/07/mocks-real-thing-tips-better-unit-testing - https://dev.to/asizikov/you-are-mocking-it-wrong-5gh3 - https://www.swiftbysundell.com/posts/mock-free-unit-tests-in-swift - https://semaphoreci.com/community/tutorials/mocking-with-rspec-doubles-and-expectations - https://tomassetti.me/mocking-in-java-why-mocking-why-not-mocking-mocking-also-those-awful-private-static-methods - https://softwareengineering.stackexchange.com/questions/363112/is-it-really-a-bad-practice-to-mock-a-pojo-value-object-if-you-dont-care-ab ou - https://stackoverflow.com/questions/6875173/to-mock-or-not-to-mock - ...
  27. 27. Thank you!

×