Rethinking Mocking: DIY Approach vs. Frameworks on examples in PHP and Typescript - SarvenDev

In the landscape of software testing, the choice between a do-it-yourself (DIY) approach to mocking and utilizing mocking frameworks is a pivotal decision for programmers. While mocking is indispensable for code reliability, its overuse or incorrect implementation can introduce complexities and fragilities within test suites. This article navigates the balance between leveraging mocks effectively and avoiding common pitfalls, including the dangers of writing mocks in a suboptimal manner.

Crell,
@Crell@phpc.social avatar

@symfonystation You forgot the benefits of anonymous classes. I almost never use a mocking framework anymore since they were added.

https://peakd.com/php/@crell/don-t-use-mocking-libraries

symfonystation,
symfonystation avatar

@Crell I did not write this but I appreciate your point.

walter_wiggles,

This is bad advice. Mocking libraries have come from many years of experience. Rolling your own test library will be like reinventing the wheel, but with less documentation and more inconsistencies.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • DreamBathrooms
  • magazineikmin
  • thenastyranch
  • Youngstown
  • slotface
  • everett
  • ngwrru68w68
  • mdbf
  • kavyap
  • tsrsr
  • Durango
  • PowerRangers
  • hgfsjryuu7
  • InstantRegret
  • normalnudes
  • khanakhh
  • osvaldo12
  • vwfavf
  • tacticalgear
  • rosin
  • cubers
  • cisconetworking
  • GTA5RPClips
  • ethstaker
  • tester
  • modclub
  • Leos
  • anitta
  • All magazines