Repository navigation
Commit dde34a2
authored
test: add Android and iOS device tests run through dotnet test --device (#4506)
## Summary
**ReactiveUI's Android and iOS platform code now has tests that run on a
real emulator and simulator, in CI and locally.**
- **`ReactiveUI.Device.Tests` replaces
`ReactiveUI.NonParallel.Mobile.Tests`.** The old project used xUnit and
NUnit runners, referenced a project that no longer exists, and was never
built.
- **The Android head runs through the .NET SDK's `dotnet test
--device`.** An instrumentation runs TUnit in the app and streams each
result back, and `dotnet test` writes the TRX report on the host.
- **The iOS head runs every test when UIKit connects its scene.** It
writes a TRX report and an exit-code file, then exits with the test
run's code.
- **Android tests cover** `HandlerSequencer`, the `WithAndroidX`
registrations, `PlatformOperations`, activity and fragment activation,
`StartActivityForResultAsync`, `ControlFetcherMixins` on views,
activities, layout hosts and AndroidX fragments, `LayoutViewHost`,
`ReactiveViewHost`, `AutoSuspendHelper`, `BundleSuspensionDriver`,
shared-preference changes, service binding, and the RecyclerView and
pager adapters.
- **iOS tests cover** `NSRunloopSequencer`, the UIKit registrations,
`ViewModelViewHost`, `RoutedViewHost`, `ReactiveViewController`
activation, `AppSupportJsonSuspensionDriver` and `IndexNormalizer`.
- **The project is in `reactiveui.slnx`, so every CI leg builds it.**
`ci-build.yml` and `sonarcloud.yml` leave it out of the host test run
with `!tests/ReactiveUI.Device.Tests/**`.
- **`device-tests.yml` runs both heads through the new actions-common
device-tests workflow.** It uses
`workflow-common-device-tests.yml@main`.
## Why
**Nothing exercised the code under `Platforms/android`, `apple-common`
and `uikit-common` or `ReactiveUI.AndroidX`, because it only runs on a
device.**
## Breaking changes
None. Only tests and CI change.
## How this was verified
**The Android head ran on a local emulator, in Debug and Release,
through the same device-tests script CI runs.**
- The iOS head builds on Windows in Debug and Release. It could not run
here: the simulator needs macOS, so its first run is this PR's
`device-tests (ios)` job.
- Run it locally with `dotnet run --file
../actions-common/scripts/device-tests.cs -- android --project
src/tests/ReactiveUI.Device.Tests/ReactiveUI.Device.Tests.csproj`; the
project README has the details.
## Notes for the reviewer
**Start with `Runner/DeviceTestSession.cs` and the two heads,
`Platforms/Android/TestInstrumentation.cs` and
`Platforms/iOS/IosTestHost.cs`; the test classes are straightforward.**
- **`Runner/ConsoleCancelKeyShim.cs` works around a TUnit 1.69 bug.**
TUnit subscribes to `Console.CancelKeyPress` at the start of a run and
skips that only in the browser, so every run on Android or iOS fails
before the first test. The shim fills the console's signal registration
with an inert one. It should go once TUnit guards Android and iOS; that
needs an issue on TUnit.
- **The iOS head sets `EnableTrimAnalyzer` to false.** The app is not
trimmed (`MtouchLink=None`), so the analysis only reports the reflection
paths the tests cover; the SDK's MSTest runner does the same. Please
confirm that is acceptable under the no-suppression rule.
- **`LayoutViewHost` with `ResolveStrategy.ExplicitOptOut` always
throws.** The host's own public `View` property is a writable `View`, so
the opt-out strategy tries to wire it by name and fails. The tests cover
opt-out on a plain view instead; the host bug is left for a separate
fix.
- **Two more behaviours look wrong and are left as they are.**
`ReactiveActivity1 parent bbe16fa commit dde34a2
83 files changed
Lines changed: 3643 additions & 776 deletions
File tree
- .github/workflows
- src
- tests
- ReactiveUI.Device.Tests
- Platforms
- Android
- Activities
- Infrastructure
- Resources
- layout
- values
- Tests
- Views
- iOS
- Infrastructure
- Tests
- Views
- Runner
- ReactiveUI.NonParallel.Mobile.Tests
- Platforms
- android
- cocoa
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments