Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tvOS tests #1928

Merged
merged 6 commits into from
Sep 23, 2022
Merged

Fixed tvOS tests #1928

merged 6 commits into from
Sep 23, 2022

Conversation

NachoSoto
Copy link
Contributor

@NachoSoto NachoSoto commented Sep 21, 2022

Turns out we hadn't been running tests on tvOS for a while:

[19:08:22]: Couldn't find any matching simulators for '["Apple TV (15.2)"]' - falling back to default simulator
[19:08:22]: Found simulator "iPhone 13 Pro (15.5)"

I found this went I went to dig into this failure. Turns out that wasn't running on tvOS anyway.

This turns them back on, fixes the compilation issues on tvOS tests, and ensures that we don't run into this issue again.

Changes:

  • Renamed device in lane test_tvos
  • Enabled ensure_devices_found on iOS and tvOS lanes. This will also ensure that we don't stop running tests on iOS XX because it doesn't find that simulator.
  • Removed UnitTestHostApp storyboards and scene, since those aren't supported in tvOS, and aren't needed because there's no UI.
  • Made StoreKitUnitTests and UnitTestHostApp targets universal
  • No longer linking AdServices on tvOS in test targets
  • Disabled attribution tests on tvOS. Those methods weren't being compiled, but we were testing that a message was being sent, even though it no longer was.
  • Changed iOS 14 tests to use Xcode 13 due to Xcode 14 simulator list blank xcpretty/xcode-install#466 (same as CircleCI: changed iOS 12/13 to use Xcode 13 #1918).

@NachoSoto NachoSoto requested a review from a team September 21, 2022 19:58
@@ -121,6 +121,7 @@ platform :ios do
scan(
step_name: "scan - iPhone",
device: ENV['SCAN_DEVICE'] || "iPhone 12 (15.2)",
ensure_devices_found: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the knowledge @joshdholtz!

Turns out we hadn't been running tests on `tvOS` for a while:
> [19:08:22]: Couldn't find any matching simulators for '["Apple TV (15.2)"]' - falling back to default simulator
> [19:08:22]: Found simulator "iPhone 13 Pro (15.5)"

This turns them back on, fixes the compilation issues on `tvOS` tests, and ensures that we don't run into this issue again.

### Changes:
- Renamed device in lane `test_tvos`
- Enabled `ensure_devices_found` on `iOS` and `tvOS` lanes. This will also ensure that we don't stop running tests on iOS XX because it doesn't find that simulator.
- Removed `UnitTestHostApp` storyboards and scene, since those aren't supported in `tvOS`, and aren't needed because there's no UI.
- Made `StoreKitUnitTests` and `UnitTestHostApp` targets universal
- No longer linking `AdServices` on `tvOS` in test targets
- Disabled attribution tests on `tvOS`. Those methods weren't being compiled, but we were testing that a message was being sent, even though it no longer was.
Comment on lines 291 to 295
- install-and-create-sim:
install-name: iOS 14.5 Simulator
sim-device-type: iPhone-8
sim-device-runtime: iOS-14-5
sim-name: iPhone 8 (14.5)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was missing now in Xcode 14.0

@@ -235,7 +235,7 @@ jobs:
command: bundle exec fastlane test_ios
no_output_timeout: 30m
environment:
SCAN_DEVICE: iPhone 13 (16.0)
SCAN_DEVICE: iPhone 14 (16.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was wrong too.

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

Just one question on deleted tests but approving because I assume there is a good reason 😊

Comment on lines -63 to -93
func testBeginRefundRequestForProductFatalErrorIfNotIosOrCatalyst() throws {
#if os(watchOS) || os(macOS) || os(tvOS)
expectFatalError(expectedMessage: Strings.purchase.begin_refund_request_unsupported.description) {
_ = try await helper.beginRefundRequest(forProduct: mockProductID)
}
#else
throw XCTSkip("beginRefundRequestForProduct is not available for this test.")
#endif
}

func testBeginRefundRequestForEntitlementFatalErrorIfNotIosOrCatalyst() throws {
#if os(watchOS) || os(macOS) || os(tvOS)
expectFatalError(expectedMessage: Strings.purchase.begin_refund_request_unsupported.description) {
_ = try await helper.beginRefundRequest(forEntitlement: mockEntitlementID)
}
#else
throw XCTSkip("beginRefundRequestForEntitlement is not available for this test.")
#endif
}

func testBeginRefundRequestForActiveEntitlementFatalErrorIfNotIosOrCatalyst() throws {
#if os(watchOS) || os(macOS) || os(tvOS)
expectFatalError(expectedMessage: Strings.purchase.begin_refund_request_unsupported.description) {
_ = try await helper.beginRefundRequestforActiveEntitlement()
}
#else
throw XCTSkip("beginRefundRequestForEntitlement is not available for this test.")
#endif
}

#if os(iOS)
Copy link
Member

Choose a reason for hiding this comment

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

Why are these being deleted? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I forgot to explain. The expectation wasn't being met (maybe it was before?). The methods aren't even being compiled anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Literally no code used that message string

@NachoSoto NachoSoto merged commit e3c0dfe into main Sep 23, 2022
@NachoSoto NachoSoto deleted the fix-tvos-tests branch September 23, 2022 17:32
NachoSoto added a commit that referenced this pull request Sep 23, 2022
Turns out we hadn't been running tests on `tvOS` for a while:
> [19:08:22]: Couldn't find any matching simulators for '["Apple TV
(15.2)"]' - falling back to default simulator
> [19:08:22]: Found simulator "iPhone 13 Pro (15.5)"

I found this went I went to dig into [this
failure](#1926 (comment)).
Turns out that wasn't running on `tvOS` anyway.

This turns them back on, fixes the compilation issues on `tvOS` tests,
and ensures that we don't run into this issue again.

### Changes:
- Renamed device in lane `test_tvos`
- Enabled `ensure_devices_found` on `iOS` and `tvOS` lanes. This will
also ensure that we don't stop running tests on iOS XX because it
doesn't find that simulator.
- Removed `UnitTestHostApp` storyboards and scene, since those aren't
supported in `tvOS`, and aren't needed because there's no UI.
- Made `StoreKitUnitTests` and `UnitTestHostApp` targets universal
- No longer linking `AdServices` on `tvOS` in test targets
- Disabled attribution tests on `tvOS`. Those methods weren't being
compiled, but we were testing that a message was being sent, even though
it no longer was.
- Changed iOS 14 tests to use Xcode 13 due to
xcpretty/xcode-install#466 (same as #1918).
@NachoSoto NachoSoto mentioned this pull request Sep 23, 2022
NachoSoto added a commit that referenced this pull request Sep 23, 2022
I blindly copy-pasted this snapshot and forgot that iOS 12 has different formatting. This was wrong in #1926.

It wasn't caught originally because we hadn't been running tests on iOS 12 until #1928.
NachoSoto added a commit that referenced this pull request Sep 23, 2022
I blindly copy-pasted this snapshot and forgot that iOS 12 has different
formatting. This was wrong in #1926.

It wasn't caught originally because we hadn't been running tests on iOS
12 until #1928.
NachoSoto pushed a commit that referenced this pull request Sep 23, 2022
**This is an automatic release.**

### Bugfixes
* `Purchases.beginRefundRequest`: ensured errors are `PublicError`
(#1913) via NachoSoto (@NachoSoto)
* `PurchaseTesterSwiftUI`: fixed macOS target (#1915) via NachoSoto
(@NachoSoto)
### Other Changes
* `SnapshotTesting`: require version 1.9.0 to keep supporting iOS 12/13
tests (#1931) via NachoSoto (@NachoSoto)
* Fixed `tvOS` tests (#1928) via NachoSoto (@NachoSoto)
* `pre-commit` hook: also verify leftover API keys in `PurchaseTester`
(#1914) via NachoSoto (@NachoSoto)
* `CircleCI`: changed iOS 12/13 to use Xcode 13 (#1918) via NachoSoto
(@NachoSoto)
* `PurchaseTesterSwiftUI`: removed unnecessary `UIApplicationDelegate`
(#1916) via NachoSoto (@NachoSoto)
* `CircleCI`: changed all jobs to use Xcode 14 (#1909) via NachoSoto
(@NachoSoto)
* `Atomic`: added unit test to verify `value`'s setter (#1905) via
NachoSoto (@NachoSoto)
* `spm build` CI job: changed to release build (#1903) via NachoSoto
(@NachoSoto)
* `StoreKitUnitTests`: compile on iOS 11.0+ (#1904) via NachoSoto
(@NachoSoto)
* `Purchases`: only expose testing data on `DEBUG` (#1902) via NachoSoto
(@NachoSoto)
* `Integration Tests`: added test to verify re-subscription behavior
(#1898) via NachoSoto (@NachoSoto)
* `IntegrationTests`: simplified `testExpireSubscription` to fix flaky
test (#1899) via NachoSoto (@NachoSoto)
* `Integration Tests`: actually verify that entitlement is active
(#1880) 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