Stabilize emulator tests with isolated AVD home fixtures - #59
Merged
Merged
Conversation
mattleibow
force-pushed
the
pr56c/02-c-package-parser
branch
from
February 17, 2026 14:37
dec9eef to
3df6818
Compare
mattleibow
force-pushed
the
pr56c/03-d-test-migrations
branch
from
February 17, 2026 14:37
5f88724 to
ce8a967
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattleibow
force-pushed
the
pr56c/03-d-test-migrations
branch
from
February 17, 2026 17:22
ce8a967 to
a093d33
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances test reliability by introducing explicit AVD home isolation for emulator and AVD manager tests, replacing the legacy AvdManagerTestsBase with a more composable fixture-based approach. The changes ensure that each test class or fixture operates in its own isolated ANDROID_AVD_HOME environment, preventing state pollution across test runs.
Changes:
- Introduced
AvdHomeScopehelper to encapsulate temporary AVD home directory lifecycle management with automatic environment variable restoration - Created
EmulatorTestsBasewith a nestedAvdCreateFixturethat combines package installation, AVD creation, and isolated AVD home scoping at the fixture level - Migrated
Emulator_Teststo use the new fixture pattern with headless emulator configuration suitable for CI environments, removing the previous CI skip annotations - Refactored
AvdManager_Teststo useAvdHomeScopedirectly per test class instance instead of inheriting from the removedAvdManagerTestsBase - Added explicit
[Collection]attribute toAvdLocator_Testsfor clarity about serialization requirements
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
AndroidSdk.Tests/Helpers/AvdHomeScope.cs |
New reusable helper that manages temporary AVD home directory creation, ANDROID_AVD_HOME environment variable scoping, and cleanup with proper error handling |
AndroidSdk.Tests/Helpers/EmulatorTestsBase.cs |
New base class providing shared emulator test infrastructure with headless options and an AvdCreateFixture for one-time AVD setup with isolated home |
AndroidSdk.Tests/Helpers/AvdManagerTestsBase.cs |
Removed legacy base class that mixed AVD home scoping with test class inheritance; replaced by AvdHomeScope composition |
AndroidSdk.Tests/Emulator_Tests.cs |
Migrated to use EmulatorTestsBase and AvdCreateFixture; added proper try-finally for emulator shutdown; removed CI skip to enable headless emulator testing on CI |
AndroidSdk.Tests/AvdManager_Tests.cs |
Refactored to use AvdHomeScope as instance field; added LocatedPathIsExpectedPath test; removed duplicate tests; ensured cleanup in Dispose |
AndroidSdk.Tests/AvdLocator_Tests.cs |
Added explicit Collection attribute for consistency and clarity about serialization requirements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this change matters
Our emulator/AVD tests can be sensitive to shared machine state, especially around AVD home paths and environment variables. This PR makes the test layer more isolated so runs are more predictable across local and CI environments.
What’s included
It migrates the AVD/emulator tests onto the newer fixture layering, introduces explicit AVD-home scoping, and removes the legacy fixture path. It also tightens cleanup and test collection behavior to reduce race conditions and leftover state between runs.
Validation
dotnet test AndroidSdk.Tests/AndroidSdk.Tests.csproj --configuration Release --filter "FullyQualifiedName~AvdLocator_Tests|FullyQualifiedName~AvdManager_Tests|FullyQualifiedName~Emulator_Tests"