Skip to content

[tests] Prune unsupported Android cases and consolidate redundant tests - #12930

Merged
jonathanpeppers merged 3 commits into
mainfrom
simonrozsival-test-cleanup
Sep 28, 2026
Merged

jonathanpeppers merged 3 commits into
mainfrom
simonrozsival-test-cleanup

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Purpose

Prune test cases that cannot run in a supported configuration and consolidate low-value tests without discarding meaningful coverage. Tests disabled for still-open bugs are retained rather than silently retired. Separate commits cover runtime-matrix pruning, redundant-test cleanup, and follow-up changes to preserve independent failure reporting.

Generate only supported runtime/release combinations

BaseTest.ValidRuntimeConfigurations supplies the three valid combinations: CoreCLR Debug, CoreCLR Release, and NativeAOT Release. These 39 active methods use a single NUnit ValueSource for the correlated (isRelease, runtime) pair; NUnit still combines that pair with each method's other [Values] dimensions. This prevents generating NativeAOT Debug cases that immediately called IgnoreUnsupportedConfiguration. NUnit discovery found 147 runnable tuple-derived cases across the host and device assemblies, with no NativeAOT Debug case in these methods.

File Methods converted; existing assertions and other dimensions remain
AndroidUpdateResourcesTest.cs DesignTimeBuild, CheckOldResourceDesignerIsNotUsed, CheckOldResourceDesignerWithWrongCasingIsRemoved, CheckThatXA1034IsRaisedForInvalidConfiguration
AssetPackTests.cs BuildLibraryWithAssetPack, BuildApplicationWithAssetPackThatHasInvalidName, BuildApplicationWithAssetPackOutsideProjectDirectory, BuildApplicationWithAssetPackOverrides, BuildApplicationWithAssetPack
BuildTest.cs CheckItemMetadata, CheckLogicalNamePathSeperators, Desugar, BuildApplicationWithJavaSourceUsingAndroidX
BuildTest2.cs BuildBasicApplication, BuildBasicApplicationThenMoveIt, XA0141ErrorIsRaised, CheckTimestamps, BuildApplicationAndClean, BuildApplicationWithLibraryAndClean, CustomApplicationClassAndMultiDex
BuildWithLibraryTests.cs BuildWithNativeLibraries, BuildLibraryWhichUsesResources
IncrementalBuildTest.cs GenerateJavaStubsAndAssembly
ManifestTest.cs ModifyManifest
PackagingTest.cs CheckAppBundle
Tasks/LinkerTests.cs WarnAboutAppDomains
TrimmableTypeMapBuildTests.cs Build_WithTrimmableTypeMap_Succeeds, Build_WithTrimmableTypeMap_IncrementalBuild
WearTests.cs BasicProject
XASdkTests.cs DotNetPublishDefaultValues
Device DebuggingTest.cs ApplicationRunsWithoutDebugger, retaining the native-library-extraction and embedded-dex dimensions
Device InstallAndRunTests.cs DeployToDevice, ActivityAliasRuns, GlobalLayoutEvent_ShouldRegisterAndFire_OnActivityLaunch, JsonDeserializationCreatesJavaHandle, AppWithStyleableUsageRuns, TypeAndMemberRemapping, FixLegacyResourceDesignerStep, GradleFBProj

The already ignored, issue-linked MicrosoftIntune and DotNetInstallAndRunPreviousSdk retain their data and ignore markers; their open bugs were not silently retired.

Stop generating NativeAOT cases where the tested behavior cannot apply

The CoreCLR cases remain. Each narrowed NativeAOT case already skipped because the artifact or mechanism being asserted does not exist there; unreachable skip/null-result paths were removed where applicable.

File Affected methods Why NativeAOT could not exercise them
BuildTest.cs ApplicationJavaClassProperties, ApplicationIdPlaceholder Debug-era behavior; NativeAOT is Release-only.
BuildTest2.cs BuildReleaseArm64; BuildBasicApplicationCheckPdb, BuildBasicApplicationCheckPdbRepeatBuild, BuildAppCheckDebugSymbols The first inspects ILLink's linked/ output, which ILC does not produce. The others check managed Debug PDB/symbol artifacts unsupported in NativeAOT Debug.
BuildTest3.cs All eight NativeLibraryJniPreload_* methods: NoDuplicates, IncludeCustomLibraries, ExcludeSomeCustomLibraries, ExcludeAllCustomLibraries, AddSomeCustomLibrariesAndIgnoreAll, AddSomeCustomLibrariesAndIgnoreAllByName, IgnoreAll_PreservesRequired, DefaultsWork NativeAOT does not use JNI preload. The common helper no longer returns a nullable, skip-shaped result; CoreCLR preload assertions still execute.
BuildWithLibraryTests.cs ProjectDependencies, MultiTfmTransitiveReference The former expects unused library JCWs intentionally removed by the NativeAOT trimmable typemap; the latter is Debug-only.
IncrementalBuildTest.cs AppProjectTargetsDoNotBreak, LinkAssembliesNoShrink, AfterILLinkAdditionalStepsIsSkippedOnSecondBuild; ChangePackageNamingPolicy The first three inspect ILLink-only outputs/targets; the last tests Lowercase naming, intentionally unsupported with the trimmable typemap.
PackagingTest.cs MissingSatelliteAssemblyInLibrary NativeAOT does not package the individual satellite assemblies inspected by this test.
Tasks/LinkerTests.cs AndroidUseNegotiateAuthentication, PreserveIX509TrustManagerSubclasses, PreserveServices, WarnWithReferenceToPreserveAttribute They inspect ILLink-linked assemblies or an ILLink warning that ILC cannot emit. The now-unused linked-assembly skip helper was removed.
Device InstallAndRunTests.cs NativeAssemblyCacheWithSatelliteAssemblies, FastDeployEnvironmentFiles, SkiaSharpCanvasBasedAppRuns Individual assemblies are absent under NativeAOT; FastDev is Debug-only; and the tested legacy resource-designer fix does not run on the NativeAOT trimmable typemap path.
Device MonoAndroidExportTest.cs MonoAndroidExportReferencedAppStarts, ExportedMembersSurviveGarbageCollection Mono.Android.Export is unsupported under NativeAOT. Both valid CoreCLR Debug/Release checks remain.

Five existing sources were narrowed without removing their test methods:

  • BuildTest2.Get_BuildHasNoWarningsData and Get_BuildHasTrimmerWarningsData: remove three NativeAOT Debug rows each, keeping seven and eleven runnable cases and their diagnostic assertions.
  • InstallAndRunTests.Get_DotNetRun_Data: remove two always-skipped NativeAOT/LLVM-IR typemap cases, keeping five cases on supported typemaps.
  • LinkerTests.Get_AndroidAddKeepAlivesData: stop generating NativeAOT cases for ILLink keep-alive checks, retaining CoreCLR and explicit trimmable-typemap compatibility cases.
  • BuildTest.Get_EnvironmentVariablesData: remove unsupported NativeAOT LowercaseMD5, keeping the other environment-variable combinations for both runtimes.

Tests ignored for still-open issues—including version-code fixtures awaiting supported ABIs, repetitive-build regressions, Intune, and broken runtime-specific paths—are not deleted.

Consolidate or repair low-signal tests without masking failures

Test file Change and rationale
Microsoft.Android.Build.BaseTasks-Tests/MemoryStreamPoolTests.cs Remove CreateStreamWriter and CreateBinaryWriter. Both wrote through MemoryStreamPool.Shared but checked reuse in an unrelated local pool. FilesTests.CopyIfStreamChanged_MemoryStreamPool_StreamWriter and _BinaryWriter already confirm return and reset on the same pool actually used. Reuse and PutDisposed remain.
Microsoft.Android.Build.BaseTasks-Tests/HexUtilitiesTests.cs Remove GetHexValue_DefaultsToUpperCase and WriteHex_Span_UpperCase; the exhaustive uppercase and every-byte tests already exercise their default arguments and values. Lowercase and boundary checks remain.
Microsoft.Android.Sdk.Analysis/Tests/DNAA0001Tests.cs Remove DNAA0001DoesNotShow, which only feeds an empty source file to the analyzer; valid Application snippets still assert no diagnostic for real code.
Microsoft.Android.Sdk.Analysis/Tests/DNAS0001Tests.cs Remove IDE0002IsNotSuppressed, which tests Roslyn's wrapper rather than our suppressor. The issue-linked ignored IDE0002IsSuppressed remains so the suppressor coverage gap stays visible.
Mono.Android-Tests/Java.Interop/JavaListTest.cs Fold the first-item Count assertion into Add, retaining its subsequent two-item check. Repair RemoveAt: previously it duplicated Insert and never removed; it now calls RemoveAt(0) and checks the remaining item and count in both generic and non-generic fixtures.
Xamarin.Android.Tools.AndroidSdk-Tests/AdbRunnerTests.cs Use one method with three independent NUnit [TestCase] cases for null, empty, and whitespace constructor paths; failure in one input can no longer mask the others. Remove three AdbPortRule equality, deconstruction, and ToString checks that only exercise compiler-generated members of a declaration-only record; parsing tests still verify rule fields.
Xamarin.Android.Tools.AndroidSdk-Tests/AvdManagerRunnerTests.cs Use four methods with twelve independent NUnit cases for null/empty/whitespace constructor path, AVD name, system image, and deletion name. Every input still asserts its exception independently. Remove Constructor_AcceptsEnvironmentVariables, which checked only that new returned non-null; the real ListAvdsAsync integration test constructs a runner with environment settings and invokes it.
Xamarin.Android.Tools.AndroidSdk-Tests/EmulatorRunnerTests.cs Use two methods with six independent NUnit cases for null/empty/whitespace emulator path and AVD name; a failure in one case does not hide the others.
Xamarin.Android.Tools.AndroidSdk-Tests/DownloadUtilsTests.cs Remove ParseChecksumFile_HashOnly_WithTrailingNewline; HashOnly and the \n row of VariousLineEndings already cover the same path.
Xamarin.Android.Tools.AndroidSdk-Tests/JdkInstallerTests.cs Move the JDK 21 discovery assertion into DiscoverAsync_ReturnsVersions, retaining its returned-version shape checks while eliminating a second live network request.
Xamarin.Android.Tools.AndroidSdk-Tests/JdkVersionInfoTests.cs Remove MutableProperties_CanBeSet and ResolvedUrl_DefaultsToNull, which merely round-trip automatic property setters or check the CLR's default null value; constructor mapping and custom ToString remain tested.
Xamarin.Android.Tools.AndroidSdk-Tests/RunnerIntegrationTests.cs Remove self-confirming checks of constructor non-null, the SDK path prefix of a path built from that SDK path, and file existence already guaranteed by tool discovery. Keep real adb/avdmanager invocations and remove now-unused SdkManager setup/teardown.
Java.Interop-Tests/Java.Interop/JniTypeUtf8Test.cs Keep four separate [Test] methods for instance/static method IDs and instance/static field IDs. An initial merge ran them sequentially and hid later coverage when an earlier assertion failed; the review follow-up restored independent execution and failure reporting. All four original UTF-8-vs-string comparisons remain.
Java.Interop-Tests/Java.Interop/SelfRegistrationTests.cs Remove a fixture whose only test had an empty body and no assertion, setup, or side effect. The Java self-registration test resource used elsewhere remains.

Local validation and limitation

  • make prepare && make all completed. An initial fresh-worktree build lacked API 37.1/37.2 reference assemblies; after locally building those API-specific Mono.Android outputs, make all succeeded without changing build-system files.
  • NUnit discovery found valid cases including BuildBasicApplication 9, BuildHasNoWarnings 7, BuildHasTrimmerWarnings 11, device ApplicationRunsWithoutDebugger 12, and DotNetRun 5; ignored Intune cases remain discoverable.
  • Focused runs: BaseTasks 24 passed; Android SDK tools originally 22 passed, then the 21 separately parameterized invalid-input cases passed after review; analyzer 14 passed / 1 previously ignored; host basic builds 9 passed / 0 skipped; warning matrices and CoreCLR JNI preload 19 passed / 0 skipped; four independent JVM UTF-8 ID tests 4 passed; on-device JavaList 28 passed; on-device MonoAndroidExportReferencedAppStarts 4 passed.
  • Local-device limitation: all five DotNetRun cases fail locally because a second physical device was attached alongside the emulator. The .NET SDK dotnet run device chooser requires an explicit --device argument in that situation; ANDROID_SERIAL and ADB_TARGET pin direct adb commands but do not override that chooser. These tests are not represented as passing. The five supported cases remain discoverable for the single-emulator CI lane.

simonrozsival and others added 2 commits September 27, 2026 00:41
Generate only supported CoreCLR and NativeAOT build configurations, omit test cases for runtime behaviors that cannot apply, and retain tests disabled for open issues.

Co-authored-by: Copilot App <[email protected]>
Retain every invalid-input and UTF-8 member-ID assertion while merging related cases, remove vacuous or compiler-generated checks, and make JavaList.RemoveAt exercise the named API.

Co-authored-by: Copilot App <[email protected]>
Copilot AI lite review requested due to automatic review settings September 26, 2026 22:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Review effort: Lite
Findings: 3 Medium severity

Open (3)
What changed in this PR

This PR prunes unsupported Android runtime combinations and consolidates redundant tests while preserving meaningful assertions.

Changes:

  • Adds a shared supported runtime configuration source.
  • Removes unsupported NativeAOT and redundant test cases.
  • Repairs and consolidates selected test coverage.
File Description
tests/​Xamarin.Android.Tools.AndroidSdk-Tests/​RunnerIntegrationTests.cs Updated as part of this pull request.
tests/​Xamarin.Android.Tools.AndroidSdk-Tests/​JdkVersionInfoTests.cs Updated as part of this pull request.
tests/​Xamarin.Android.Tools.AndroidSdk-Tests/​JdkInstallerTests.cs Updated as part of this pull request.
tests/​Xamarin.Android.Tools.AndroidSdk-Tests/​EmulatorRunnerTests.cs Updated as part of this pull request.
tests/​Xamarin.Android.Tools.AndroidSdk-Tests/​DownloadUtilsTests.cs Updated as part of this pull request.
tests/​Xamarin.Android.Tools.AndroidSdk-Tests/​AvdManagerRunnerTests.cs Updated as part of this pull request.
tests/​Xamarin.Android.Tools.AndroidSdk-Tests/​AdbRunnerTests.cs Updated as part of this pull request.
tests/​MSBuildDeviceIntegration/​Tests/​MonoAndroidExportTest.cs Updated as part of this pull request.
tests/​MSBuildDeviceIntegration/​Tests/​InstallAndRunTests.cs Updated as part of this pull request.
tests/​MSBuildDeviceIntegration/​Tests/​DebuggingTest.cs Updated as part of this pull request.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​JavaListTest.cs Updated as part of this pull request.
tests/​Microsoft.Android.Build.BaseTasks-Tests/​MemoryStreamPoolTests.cs Updated as part of this pull request.
tests/​Microsoft.Android.Build.BaseTasks-Tests/​HexUtilitiesTests.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​XASdkTests.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​WearTests.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Utilities/​BaseTest.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​TrimmableTypeMapBuildTests.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​LinkerTests.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​PackagingTest.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​ManifestTest.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​IncrementalBuildTest.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildWithLibraryTests.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest3.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest2.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​AssetPackTests.cs Updated as part of this pull request.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​AndroidUpdateResourcesTest.cs Updated as part of this pull request.
src/​Microsoft.Android.Sdk.Analysis/​Tests/​DNAS0001Tests.cs Updated as part of this pull request.
src/​Microsoft.Android.Sdk.Analysis/​Tests/​DNAA0001Tests.cs Updated as part of this pull request.
external/​Java.Interop/​tests/​Java.Interop-Tests/​Java.Interop/​SelfRegistrationTests.cs Updated as part of this pull request.
external/​Java.Interop/​tests/​Java.Interop-Tests/​Java.Interop/​JniTypeUtf8Test.cs Updated as part of this pull request.

Comment thread tests/Xamarin.Android.Tools.AndroidSdk-Tests/AdbRunnerTests.cs Outdated
Comment thread tests/Xamarin.Android.Tools.AndroidSdk-Tests/EmulatorRunnerTests.cs Outdated
Parameterize invalid-input tests so each null, empty, and whitespace value runs independently; restore separate JNI member-kind checks so one failure cannot mask the others.

Co-authored-by: Copilot App <[email protected]>
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

❌ Android PR Reviewer failed. Please review the logs for details.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Generated by Android PR Reviewer for #12930

@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12930

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ LGTM — 0 errors, 0 warnings, 1 suggestion.

The runtime-matrix pruning matches the supported configurations, the follow-up parameterization preserves independent invalid-input and JNI coverage, and the removed tests are redundant or vacuous as described. CI is green across all 44 reported checks. I left one non-blocking suggestion to preserve complete assertion reporting in the consolidated JDK discovery test.

Generated by Android PR Reviewer for #12930 · copilot · gpt56 · 755 AIC · ⌖ 11.1 AIC · ⊞ 25.9K
Comment /review to run again

return;
}

Assert.That (versions.Select (v => v.MajorVersion), Does.Contain (21), "Should contain JDK 21");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 💡 Testing — Please consider wrapping this check and the per-version shape checks below in Assert.Multiple. Consolidating the former independent JDK 21 test avoids a second network request, but a missing JDK 21 now aborts this method before malformed display names or download URLs are reported; multiple assertions preserve the consolidation while keeping all failures visible.

Rule: Preserve independent test coverage

@jonathanpeppers
jonathanpeppers merged commit df4dcef into main Sep 28, 2026
44 checks passed
@jonathanpeppers
jonathanpeppers deleted the simonrozsival-test-cleanup branch September 28, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants