The iOS SDK has become impossible to mock in v4

  • 29 April 2022
  • 2 replies

Badge +2

The new revenue cat v4 SDK for iOS is very difficult if not impossible to mock for unit testing purposes. Some of the contributing factors that make mocking difficult are:

  1. The majority of classes like Offerings, Offering, Package, etc are marked as final so they can’t be subclassed. So something like class MockOfferings: Offerings {} cannot be done.
  2. The majority of initializers for classes like Offerings, Offering, Package are internal so they cannot be called from outside the package

These issues are blocking upgrading to v4 since it breaks all the existing unit tests without a new way to fix them. Is there any sample code available that successfully mocks the RevenueCat SDK?

2 replies

Badge +4

Have the same issue with unit tests breaking with v4. Has anyone found a solution to this?

Adding below code to my unit test files let me use the convenience initializers

@testable import RevenueCat