Skip to content

No on-device test project exists, so DI wiring, Android-only behaviour and page lifecycle are unverified until someone runs the app #169

Open

Description

@zhollis21

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:

  1. 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.
  2. Android-only behaviour the app depends on. The clearest case: AniListClient.cs:885-890 treats System.Net.WebException as a possible cancellation because AndroidMessageHandler reports 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, Preferences and the WorkManager scheduling path are in the same position — off-device they throw NotImplementedInReferenceAssemblyException, so no unit test reaches them.
  3. Page lifecycle on a real Shell. That is UI tests: nothing can catch page-lifecycle bugs on pushed detail pages #131: OnAppearing does 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 --device on Android today; the comment of 2026-11-13 has the details.
  • Whether a net11.0-android test project can project-reference src/AniSprinkles/ (an Exe with UseMaui) to resolve the real container is untested.
  • One community report says the Android adapter does not forward --filter to 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

Related

Activity

  1. added
    p3-medium
    Tech Debt
    on Nov 11, 2026
  2. zhollis21 commented on Nov 12, 2026

    @zhollis21
    OwnerAuthor

    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 GetMedia outage recovered through RetryButton all ran as maui devflow batch scripts against fixtures. Microsoft.Maui.Testing / dotnet new mauitest was not tried: the template is not installed on this machine.

  3. zhollis21 commented on Nov 12, 2026

    @zhollis21
    OwnerAuthor

    Spike for nunit/nunit3-vs-adapter#175, 2026-11-12, on emulator-5554, SDK 11.0.100: can the androidtest template run NUnit instead of MSTest?

    • Stock template (MSTest 4.3.2), control: dotnet test --device runs and reports results (3 tests: 1 passed, 1 failed, 1 skipped, as generated).

    • NUnit through MTP: swapped builder.AddMSTest(...) for builder.AddNUnit(...) (NUnit 5.0.0, NUnit3TestAdapter 6.3.1, EnableNUnitRunner). It builds, but every run fails before any test executes:
      PlatformNotSupportedException at System.Console.add_CancelKeyPress ← NUnit3TestExecutor..ctor(Boolean isMTP) (NUnit3TestExecutor.cs:128). In MTP mode the adapter subscribes to Console.CancelKeyPress with no platform guard; Android throws on that. The same code is on the adapter's main today, and 6.3.1 is the latest release.
      Separately, Microsoft.Testing.Extensions.TrxReport has to match the MTP version the adapter pulls in (2.4.1), or it fails with MissingMethodException.

    • NUnit without MTP: an Instrumentation that calls NUnitTestAssemblyRunner directly (NUnit 5.0.0 only, no adapter) ran on the device: 6 tests including two [TestCase] rows, an async test using TestContext.CurrentContext.CancellationToken, and a deliberate failure reported with its assertion message. It is run with adb shell am instrument, not dotnet test --device, and writes no TRX.

    • Reported upstream: MTP mode throws PlatformNotSupportedException on Android: NUnit3TestExecutor subscribes to Console.CancelKeyPress nunit/nunit3-vs-adapter#1549.

  4. zhollis21 commented on Nov 13, 2026

    @zhollis21
    OwnerAuthor

    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 androidtest project with dotnet test --device (SDK 11.0.100, net11.0-android, x86_64 emulator, API 36), Debug and Release:

    We rejected the other way to keep a single framework: driving NUnitTestAssemblyRunner from our own Instrumentation, as in the earlier spike. That runs, but only through adb shell am instrument, with no dotnet 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.

  5. zhollis21 commented on Nov 20, 2026

    @zhollis21
    OwnerAuthor

    Checked 2026-11-19 against origin/main at a04a306.

  6. zhollis21 commented on Nov 21, 2026

    @zhollis21
    OwnerAuthor

    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 read nunit/nunit3-vs-adapter#… and linked to the adapter repo, and moved the emulator citation to ci-build-and-preview.yml:1339-1348, API 37.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Tech Debtp3-medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions