Skip to content

StoreKit2StorefrontListener: added tests to fix flaky code coverage#2265

Merged
NachoSoto merged 3 commits into
mainfrom
storefront-listener-test-delegate
Feb 8, 2023
Merged

StoreKit2StorefrontListener: added tests to fix flaky code coverage#2265
NachoSoto merged 3 commits into
mainfrom
storefront-listener-test-delegate

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Feb 6, 2023

Copy link
Copy Markdown
Contributor

Similarly to #2262, test execution ordering was leading to flaky code coverage results with this.

Screenshot 2023-02-06 at 10 48 45

Because we didn't have any test coverage, only if some other test changed the Storefront, this test was calling the delegate code.

This adds explicit test coverage using a MockAsyncSequence.

Other changes:

  • Added StorefrontType to StoreKit2StorefrontListenerDelegate method
  • Storefront initializers are no longer Optional init?
  • Simplified StoreKit2StorefrontListenerTests by moving AvailabilityChecks to setUp

@NachoSoto NachoSoto added the test label Feb 6, 2023
@NachoSoto NachoSoto requested a review from a team February 6, 2023 18:48
@NachoSoto NachoSoto force-pushed the storefront-listener-test-delegate branch 2 times, most recently from dd1d8f4 to 0464b98 Compare February 6, 2023 21:06
@RevenueCat RevenueCat deleted a comment from codecov Bot Feb 6, 2023
@codecov

codecov Bot commented Feb 6, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2265 (21e2d71) into main (6384246) will increase coverage by 0.10%.
The diff coverage is 95.23%.

@@            Coverage Diff             @@
##             main    #2265      +/-   ##
==========================================
+ Coverage   86.07%   86.17%   +0.10%     
==========================================
  Files         186      186              
  Lines       12269    12282      +13     
==========================================
+ Hits        10560    10584      +24     
+ Misses       1709     1698      -11     
Impacted Files Coverage Δ
...s/Purchasing/StoreKitAbstractions/Storefront.swift 62.50% <50.00%> (+14.28%) ⬆️
...s/Purchasing/Purchases/PurchasesOrchestrator.swift 85.92% <100.00%> (ø)
...hasing/StoreKit2/StoreKit2StorefrontListener.swift 100.00% <100.00%> (ø)
Sources/Support/ManageSubscriptionsHelper.swift 70.10% <0.00%> (+2.06%) ⬆️
...s/Logging/Strings/ManageSubscriptionsStrings.swift 81.25% <0.00%> (+6.25%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

)
}

init<S: AsyncSequence>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a description and sample usage here, this init won't be intuitive to folks not very used to Swift

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment explaining this.

Similarly to #2262, test execution ordering was leading to [flaky code coverage results](https://app.codecov.io/gh/RevenueCat/purchases-ios/pull/2262) with this.
Because we didn't have any test coverage, only if some other test changed the `Storefront`, this test was calling the delegate code.

This adds explicit test coverage using a `MockAsyncSequence`.

- Added `StorefrontType` to `StoreKit2StorefrontListenerDelegate` method
- `Storefront` initializers are no longer `Optional` `init?`
- Simplified `StoreKit2StorefrontListenerTests` by moving `AvailabilityChecks` to `setUp`
@NachoSoto NachoSoto force-pushed the storefront-listener-test-delegate branch from d1ff43b to 21e2d71 Compare February 8, 2023 20:17
@NachoSoto NachoSoto merged commit 32d10a9 into main Feb 8, 2023
@NachoSoto NachoSoto deleted the storefront-listener-test-delegate branch February 8, 2023 20:45
NachoSoto pushed a commit that referenced this pull request Feb 15, 2023
**This is an automatic release.**

### Bugfixes
* `PurchaseOrchestrator`: always refresh receipt purchasing in sandbox
(#2280) via NachoSoto (@NachoSoto)
* `BundleSandboxEnvironmentDetector`: always return `true` when running
on simulator (#2276) via NachoSoto (@NachoSoto)
* `OfferingsManager`: ensure underlying
`OfferingsManager.Error.configurationError` is logged (#2266) via
NachoSoto (@NachoSoto)
### Other Changes
* `UserDefaultsDefaultTests`: fixed flaky failures (#2284) via NachoSoto
(@NachoSoto)
* `BaseBackendTest`: improved test failure message (#2285) via NachoSoto
(@NachoSoto)
* Updated targets and schemes for Xcode 14.2 (#2282) via NachoSoto
(@NachoSoto)
* `HTTPRequest.Path.health`: don't cache using `ETagManager` (#2278) via
NachoSoto (@NachoSoto)
* `EntitlementInfos.all`: fixed docstring (#2279) via NachoSoto
(@NachoSoto)
* `StoreKit2StorefrontListener`: added tests to fix flaky code coverage
(#2265) via NachoSoto (@NachoSoto)
* `NetworkError`: added underlying error to description (#2263) via
NachoSoto (@NachoSoto)
* Created `Signing.verify(message:hasValidSignature:with:)` (#2216) via
NachoSoto (@NachoSoto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants