Skip to content

Stabilize emulator tests with isolated AVD home fixtures - #59

Merged
mattleibow merged 1 commit into
mainfrom
pr56c/03-d-test-migrations
Feb 17, 2026
Merged

mattleibow merged 1 commit into
mainfrom
pr56c/03-d-test-migrations

Conversation

@mattleibow

@mattleibow mattleibow commented Feb 17, 2026 •

Copy link
Copy Markdown
Collaborator

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"

@mattleibow mattleibow changed the title test: PR-D avd/emulator test migration test: refactor emulator fixtures with isolated AVD homes Feb 17, 2026
@github-actions

github-actions Bot commented Feb 17, 2026 •

Copy link
Copy Markdown

Test Results

76 tests   - 2   73 ✅ ±0   10m 5s ⏱️ -22s
 2 suites ±0    3 💤  - 2 
 2 files   ±0    0 ❌ ±0 

Results for commit a093d33. ± Comparison against base commit 3df6818.

♻️ This comment has been updated with latest results.

@mattleibow
mattleibow force-pushed the pr56c/02-c-package-parser branch from dec9eef to 3df6818 Compare February 17, 2026 14:37
@mattleibow
mattleibow force-pushed the pr56c/03-d-test-migrations branch from 5f88724 to ce8a967 Compare February 17, 2026 14:37
@mattleibow mattleibow changed the title test: refactor emulator fixtures with isolated AVD homes Stabilize emulator tests with isolated AVD home fixtures Feb 17, 2026
@mattleibow
mattleibow requested a review from Copilot February 17, 2026 17:19
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattleibow
mattleibow force-pushed the pr56c/03-d-test-migrations branch from ce8a967 to a093d33 Compare February 17, 2026 17:22
@mattleibow
mattleibow changed the base branch from pr56c/02-c-package-parser to main February 17, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 AvdHomeScope helper to encapsulate temporary AVD home directory lifecycle management with automatic environment variable restoration
  • Created EmulatorTestsBase with a nested AvdCreateFixture that combines package installation, AVD creation, and isolated AVD home scoping at the fixture level
  • Migrated Emulator_Tests to use the new fixture pattern with headless emulator configuration suitable for CI environments, removing the previous CI skip annotations
  • Refactored AvdManager_Tests to use AvdHomeScope directly per test class instance instead of inheriting from the removed AvdManagerTestsBase
  • Added explicit [Collection] attribute to AvdLocator_Tests for 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.

Comment thread AndroidSdk.Tests/AvdManager_Tests.cs
Comment thread AndroidSdk.Tests/AvdManager_Tests.cs
@mattleibow
mattleibow merged commit 73677f4 into main Feb 17, 2026
5 checks passed
@mattleibow
mattleibow deleted the pr56c/03-d-test-migrations branch February 17, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants