18

*Achievement unlocked*

The award of:
Asking “Can you please fucking enable some way for me to mock the networking requests?” A record number of times to unique third party libraries in a week

Awarded to:
practiseSafeHex

Comments
  • 3
    Omg yay! Woop woop
  • 0
    Hurrah!! 🥳
  • 0
    I’d like that with googles api
  • 0
    Careful.
    If all your tests are mocks, they lose the ability to be tests and instead become some sort of spec document detailing what should happen rather than testing against what is actually happening.
  • 0
    @nitnip well part of it is testing for fail points in your choice of software libs and the like too
    Like request promise throws in catchable exceptions sometimes
  • 0
    @nitnip It should be clear what you're testing and what you're mocking...

    But you don't want to create a user, fill a shopping cart, go through checkout and shipping for every test of the invoice system.

    And while sometimes testing database persistence is useful, you certainly don't want your tests to depend on external APIs outside of your control. Not even sandbox APIs.
  • 0
    @nitnip I am very pro “test the actual code”. But there are many situations where that’s not possible or practical.

    My use case is a third party library that has an embedded social media login feature. I have to put a lot of logic around this and want to test that. But I can’t have my unit tests logging into Twitter accounts. So I need a way to mock that and just return a dummy object from this SDK

    This library has a shit tonne of classes and constructors marked as private or final so I can’t subclass or touch them. And the networking code is hidden away so I can’t stub that either
Add Comment