Repository navigation
Description
Found while planning the .NET 11 migration (#168), 2026-11-11, against origin/main at f7d84a2.
Problem
Every automated test in the repo runs off-device. tests/ holds one project, AniSprinkles.UnitTests, on plain net10.0, and it can only reference src/AniSprinkles.Core/. Everything in the MAUI app project, and every behaviour that only exists on Android, is verified by a person running the app.
AGENTS.md:70 says tests/AniSprinkles.UITests/ "is still a scaffold for future device tests", and #131 repeats it. That directory does not exist — ls tests returns AniSprinkles.UnitTests only, and git ls-files tests has no UITests entry.
Three kinds of thing fall through:
- DI wiring. A missing registration is a runtime crash on the first resolve. That is Add startup DI-resolution smoke test to catch missing registrations #65.
- Android-only behaviour the app depends on. The clearest case:
AniListClient.cs:885-890treatsSystem.Net.WebExceptionas a possible cancellation becauseAndroidMessageHandlerreports a cancelled read that way. That rule was learned on device and is pinned by nothing. The .NET 11 move to CoreCLR is exactly the kind of change that could alter it silently.SecureStorage,Preferencesand the WorkManager scheduling path are in the same position — off-device they throwNotImplementedInReferenceAssemblyException, so no unit test reaches them. - Page lifecycle on a real Shell. That is UI tests: nothing can catch page-lifecycle bugs on pushed detail pages #131:
OnAppearingdoes not fire on a pushed page when its tab becomes current again, and no test at the page-model layer can see it.
What .NET 11 adds
Verified locally with SDK 11.0.100:
dotnet new androidtest -n ProbeTests
generates a net11.0-android project with MSTest 4.3.2, EnableMSTestRunner, an AndroidManifest.xml, a TestInstrumentation.cs that builds a Microsoft.Testing.Platform test application and writes a TRX report, and a global.json selecting MTP as the repo's test runner. dotnet test builds, installs and runs it through Android instrumentation, with --device to pick an emulator.
What that is and is not:
- It runs in its own app process. It is a separate test app, not our app under test, and it does not drive UI. That fits kinds 1 and 2 above, not kind 3.
- It is MSTest, and the device tests will stay on MSTest (decided 2026-11-13). The unit tests are NUnit (Move the unit tests from xunit to NUnit, the framework KingdomWatch already uses (#175) #185). Neither NUnit nor xunit v3 runs under
dotnet test --deviceon Android today; the comment of 2026-11-13 has the details. - Whether a
net11.0-androidtest project can project-referencesrc/AniSprinkles/(anExewithUseMaui) to resolve the real container is untested. - One community report says the Android adapter does not forward
--filterto the on-device process.
For kind 3 there are two candidates, both preview: Microsoft.Maui.Testing with the mauitest template (0.1.0-preview.14, .NET 11 only, not on Microsoft Learn yet), and driving the real app through MAUI DevFlow (#170).
Options
Partly settled. Decided so far (2026-11-11): we want both — DI/platform pins and UI journeys — rather than one or the other. Decided 2026-11-20: kind 3 is #131, built as host-side NUnit tests that drive the real app through DevFlow (Microsoft.Maui.DevFlow.Client), so this issue's remaining scope is kinds 1 and 2.
A. androidtest for kinds 1 and 2, a separate harness for kind 3. Uses the supported template for what it is good at. Costs a second test framework in the repo and two harnesses to keep alive in CI.
B. One UI-driving harness for everything. mauitest or DevFlow drives the real app, and the DI smoke test becomes "the app launches". Fewer moving parts; but a launch only proves the registrations reached at startup, which is weaker than #65 asks for, and platform pins like the cancellation exception type are awkward to reach through UI.
C. androidtest only, keep #131's rule-based answer. Cheapest. Leaves page lifecycle to manual device verification, which is the status quo #131 objects to.
Leaning A, starting with the cancellation pin because the .NET 11 migration needs that answer anyway. A starting point for kickoff, not a decision.
Constraint
- CI already boots one emulator (
ci-build-and-preview.yml:1339-1348, API 37.0,x86_64). Device tests should reuse that boot rather than add a second. - Opting into MTP in
global.jsonapplies to every test project; the unit tests move to MTP as part of .NET 11 removes Mono: the retarget, with the Release gate, MTP, XAML source generation and build hygiene #168, so this must land after that. - Nothing here may call the live AniList API from CI. Device tests need the same fixture replay the
-p:CiBuild=truebuild uses, or no network at all.
Related
- .NET 11 removes Mono: the retarget, with the Release gate, MTP, XAML source generation and build hygiene #168 — the .NET 11 migration; MTP and
net11.0-androidare preconditions. - Add startup DI-resolution smoke test to catch missing registrations #65 — DI-resolution smoke test; first consumer.
- UI tests: nothing can catch page-lifecycle bugs on pushed detail pages #131 — page-lifecycle bugs on pushed pages; the UI-journey consumer.
- Nothing builds or launches a Release build before it ships, so trimming/AOT failures reach users #155 — Release build-and-launch gate; overlaps in part, since both launch a real build in CI.
- driver.ps1 reads the UI by scraping uiautomator XML; evaluate MAUI DevFlow as the maintained replacement #170 — DevFlow evaluation; one candidate for the UI-journey harness.
Activity
zhollis21 commentedon Nov 12, 2026
From nunit/nunit3-vs-adapter#170 (2026-11-12), for the UI-journey half of this: MAUI DevFlow now ships in every Debug build (#182) and drives the real app on the emulator — a card tap into details, a favourite toggle, and an injected
GetMediaoutage recovered throughRetryButtonall ran asmaui devflow batchscripts against fixtures.Microsoft.Maui.Testing/dotnet new mauitestwas not tried: the template is not installed on this machine.zhollis21 commentedon Nov 12, 2026
Spike for nunit/nunit3-vs-adapter#175, 2026-11-12, on
emulator-5554, SDK 11.0.100: can theandroidtesttemplate run NUnit instead of MSTest?Stock template (MSTest 4.3.2), control:
dotnet test --deviceruns and reports results (3 tests: 1 passed, 1 failed, 1 skipped, as generated).NUnit through MTP: swapped
builder.AddMSTest(...)forbuilder.AddNUnit(...)(NUnit5.0.0,NUnit3TestAdapter6.3.1,EnableNUnitRunner). It builds, but every run fails before any test executes:PlatformNotSupportedExceptionatSystem.Console.add_CancelKeyPress←NUnit3TestExecutor..ctor(Boolean isMTP)(NUnit3TestExecutor.cs:128). In MTP mode the adapter subscribes toConsole.CancelKeyPresswith no platform guard; Android throws on that. The same code is on the adapter'smaintoday, and 6.3.1 is the latest release.Separately,
Microsoft.Testing.Extensions.TrxReporthas to match the MTP version the adapter pulls in (2.4.1), or it fails withMissingMethodException.NUnit without MTP: an
Instrumentationthat callsNUnitTestAssemblyRunnerdirectly (NUnit 5.0.0 only, no adapter) ran on the device: 6 tests including two[TestCase]rows, an async test usingTestContext.CurrentContext.CancellationToken, and a deliberate failure reported with its assertion message. It is run withadb shell am instrument, notdotnet test --device, and writes no TRX.Reported upstream: MTP mode throws PlatformNotSupportedException on Android: NUnit3TestExecutor subscribes to Console.CancelKeyPress nunit/nunit3-vs-adapter#1549.
Move the unit tests from xunit to NUnit, the framework KingdomWatch a…
zhollis21 commentedon Nov 13, 2026
Decision (2026-11-13): the on-device project uses MSTest. The unit tests stay on NUnit (#185).
This is why. Each framework was tried in the stock
dotnet new androidtestproject withdotnet test --device(SDK 11.0.100, net11.0-android, x86_64 emulator, API 36), Debug and Release:MSTest 4.3.2: works as generated, in Debug and Release, with a TRX report and MTP's standard summary output.
NUnit 5.0.0 + NUnit3TestAdapter: no test reaches the device.
Console.CancelKeyPresscrash above is fixed in Skip Console.CancelKeyPress where the platform does not support it nunit/nunit3-vs-adapter#1550 (for MTP mode throws PlatformNotSupportedException on Android: NUnit3TestExecutor subscribes to Console.CancelKeyPress nunit/nunit3-vs-adapter#1549)./data/user/0. In Release it can't loadnunit.engine.dll, becauseAssembly.Locationis empty inside the APK. With both patched locally, it still can't load the test assembly.dotnet test --devicefails inside the NUnit engine nunit/nunit-console#1966. NUnit through the adapter looks never to have run on Android; the old in-app runner, nunit.xamarin, has been archived since 2022.xunit v3 (
xunit.v3.mtp-v24.0.3): fails the build on purpose. The Android SDK turnsOutputTypeExe into Library, and xunit rejects that. With the check overridden, Debug runs (1 passed / 1 failed / 1 skipped), but only after two more workarounds:Assembly.SetEntryAssembly, because there is no entry assembly;Console.SetIn(TextReader.Null), because xunit readsConsole.In, which throws on Android.Release still fails, on
Path.GetFullPath("").We rejected the other way to keep a single framework: driving
NUnitTestAssemblyRunnerfrom our ownInstrumentation, as in the earlier spike. That runs, but only throughadb shell am instrument, with nodotnet test --device, no TRX and its own CI parsing. If nunit/nunit-console#1966 is resolved upstream, moving the device tests to NUnit is worth another look.Move the unit tests from xunit to NUnit, the framework KingdomWatch a…
zhollis21 commentedon Nov 20, 2026
Checked 2026-11-19 against
origin/mainata04a306.global.jsonselectsMicrosoft.Testing.Platformas the test runner, and the unit tests run on it (AGENTS.md:76-81).AGENTS.mdno longer callstests/AniSprinkles.UITests/a scaffold;AGENTS.md:81says there is no device-test project yet.AniListClient.cs:885-890still treatsSystem.Net.WebExceptionas a possible cancellation.37.0(ci-build-and-preview.yml:1339-1348), not API 34 at lines 971-976.build-releasejob, line 289; gate described at line 353).Microsoft.Maui.TestingandMicrosoft.Maui.Testing.Templatesare on NuGet at0.1.0-preview.14.26567.2. The package describes itself as a "device test application lifecycle and builder"; themauitesttemplate is aUseMauiExeon MSTest 4.3.2, and the maui-labs README lists "an NUnit configuration path".Microsoft.Maui.Build.AppProjectReference(maui-labs) lets a test project declare<MauiAppProjectReference>to a MAUI app and consume its built.apkas@(MauiAppArtifact)items.Microsoft.Maui.DevFlow.Client(AgentClient,netstandard2.0/net8.0) is on NuGet at the agent's version,0.1.0-preview.14.26555.2.nunit/nunit3-vs-adapter#131,#65,#155,#168,#170, which link to the adapter repo rather than here.zhollis21 commentedon Nov 21, 2026
Updated during planning: kind 3 is now #131 (host-side NUnit +
Microsoft.Maui.DevFlow.Client), so this issue keeps kinds 1 and 2. Also fixed every reference to this repo's issues, which readnunit/nunit3-vs-adapter#…and linked to the adapter repo, and moved the emulator citation toci-build-and-preview.yml:1339-1348, API 37.0.