Commit Graph
16 Commits
Author SHA1 Message Date
NachoSoto 15df832fea Xcode 15.3 beta 2: remove nonisolated workaround (#3640)
See #3599.

This is listed in the [release
notes](https://developer.apple.com/documentation/xcode-release-notes/xcode-15_3-release-notes)
as fixed.
2024-02-06 14:11:16 -08:00
NachoSoto d0bb035b72 Xcode 15.3 beta 1: fix warnings on tests (#3600)
Depends on #3599.
2024-01-26 08:41:38 +01:00
NachoSoto 9add1c9cb8 Tests: added missing super.setUp() (#2804) 2023-07-13 05:31:21 -07:00
NachoSoto 7f875ae212 Changed Logger to use os_log (#2608) 2023-06-15 15:13:48 -07:00
NachoSoto fdd394a884 Tests: fixed crash on iOS 13 (#2624)
This broke in #2616 because `SKTestSession` is `nil` when the tests are
skipped.

Fixes
https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/11773/workflows/c554f77d-7ea3-447c-ae54-099117eb1797/jobs/76416
2023-06-13 09:58:25 +02:00
NachoSoto 2a95520b98 StoreKitConfigTestCase/BaseStoreKitIntegrationTests: also clear transactions after every test (#2616)
Trying to work around `FB11799675`, this was suggested by @joshdholtz
and it seems to be working really well. This now calls
`deleteAllTransactions` and `SKTestSession.clearTransactions` _after_
every test, not only before.

The problem is that `clearTransactions` only seems to delete stuff from
`SKTestSession.allTransactions`, but not from
`StoreKit.Transaction.unfinished`. Doing this at the end of every test
seems to do a much better job at ensuring that each test invocation has
no leftover transaction, hopefully leading to fewer flaky failures.
2023-06-12 08:52:09 -07:00
NachoSoto db17623197 Improved finishAllUnfinishedTransactions (#2615) 2023-06-12 07:07:13 -07:00
NachoSoto 6db70b8e5e StoreKitConfigTestCase: improved waitForStoreKitTestIfNeeded (#2614) 2023-06-12 07:06:22 -07:00
NachoSoto 8cad929927 StoreKitConfigTestCase: set continueAfterFailure to false (#2617) 2023-06-12 07:05:46 -07:00
NachoSoto 2fff5b0b75 CI: also run tests on watchOS (#2340)
This is a follow up to #717.
In order to be able to reproduce #2338, which seems to be an issue only
on `watchOS`, it's important that we now run tests on `watchOS` as well.
We probably won't be able to fully replicate that issue since we don't
run tests on actual devices, so they'll still run on 64 bits. But this
way we might be able to prevent issues that are only reproducible on
`watchOS` in the future.

## Changes:
- Added CircleCI job
- Added lane
- Simplified `UnitTestsHostApp` definition using `SwiftUI`
- Increased _test only_ `watchOS` deployment target to 7.0 (this was
necessary to be able to have a common `@main` for the host app)
- Increased _test only_ `tvOS` deployment target to `14.0` (same as
above, plus we only run tvOS tests on the latest version anyway. We test
backwards compatibility through iOS already)
- Fixed test compilation on `watchOS`
- Disabled `HTTPClient` tests on `watchOS` (see
https://github.com/AliSoftware/OHHTTPStubs/issues/287)
- `StoreKitConfigTestCase` is only available from `watchOS 7.0` since
that's when `SKTestSession` was introduced
- Added `watchOS` support to `UnitTests` target
- Added `watchOS` support to `ReceiptParserTests` target
- Fixed `isFamilySharable` `watchOS` version checks for version 8.0
- Created new `CI-RevenueCat` Test Plan to only run unit tests and not
StoreKit tests on `watchOS`
2023-03-16 13:11:24 -07:00
NachoSoto cd4e33cfe8 SKTestSession: finish all unfinished transactions before starting each test (#2066)
Filed this as `FB11799675`. I noticed some tests began with prior
transactions (despite using `SKTestSession.clearTransactions`), so this
workaround ensures each test begins in a clean state.
2022-11-25 16:20:15 -08:00
NachoSoto a9874f86a1 StoreKitUnitTests: compile on iOS 11.0+ (#1904)
The entire target had a deployment target of iOS 14.0 because
`SKTestSession` requires it. However, not all tests in that target use
`StoreKitConfigTestCase`, and those weren't running before iOS 14.0.

To fix this, I've removed the deployment target overrides from all
targets (expect for integration tests, those have a higher one for
simplicity), and instead defined them only once at the *project level*,
so all targets inherit that automatically.

`StoreKitConfigTestCase` will skip the test automatically if the iOS is
below 14.0, but the other tests will now run on iOS 12 and 13.
2022-09-15 10:08:49 -07:00
NachoSoto 948314cf50 StoreKitConfigTestCase: delete Bundle.appStoreReceiptURL after every test (#1700)
Equivalent to #1671 but for unit tests.

In iOS 16 (as of beta 1), the receipt persists across tests, despite the use of `SKTestSession.resetToDefaultState`.
This might also help with flaky tests pre-iOS 16 too.

Also note that I fixed this method in `BaseBackendIntegrationTests`. Using `URL.absoluteString` was incorrect there, so the file was probably never deleted.

I filed a feedback (FB10252944) for this:
![Screen Shot 2022-06-14 at 11 27 13](https://user-images.githubusercontent.com/685609/173662482-edae8bb9-48a2-432a-9823-c07a46e8861a.png)
2022-06-14 15:02:08 -07:00
Joshua Liebowitz 9bde89137c Create Configuration object and API to configure Purchases (#1556)
* Resolves [CF-443]
* Adds `configureWithConfiguration` to `RCPurchasesAPI.m`
* Create Configuration object and API to configure Purchases
* Update API doc for new Purchases API
* Add example code to Configuration documentation
* Adds deprecations for various Purchases.configure methods
2022-05-12 15:43:10 -07:00
NachoSoto c987f10266 Created TestCase superclass to allow re-generating snapshots (#1559)
## Motivation:

There is no way to run code statically like in Obj-C using `+ [NSObject initialize]`, so this ensures (through a new `SwiftLint` rule) that all test classes inherit this common test class instead of `XCTestCase` directly.
A future PR will make use of this new `CIRCLECI_TESTS_GENERATE_SNAPSHOTS` environment variable to allow regenerating snapshots in CI.

I've also moved the duplicated `CurrentTestCaseTracker` usages to a single point.
2022-05-10 12:40:40 -07:00
aboedo d1ddd6bf9c Clean up tests folders (#1402)
* moved test suites to Tests folder

* fixed outdated path

* fixed more outdated paths

* moved TestsPlans to Tests folder

* update path to Constants.swift
2022-03-21 10:26:00 -03:00