Skip to content

Refactor environment/device creation and AdaptiveRemoteHost lifetime …#90

Open
jodavis wants to merge 3 commits intomainfrom
dev/jodavis/ADR-131-e2e-tests-share-host
Open

Refactor environment/device creation and AdaptiveRemoteHost lifetime …#90
jodavis wants to merge 3 commits intomainfrom
dev/jodavis/ADR-131-e2e-tests-share-host

Conversation

@jodavis
Copy link
Owner

@jodavis jodavis commented Feb 19, 2026

…so that the same host can be shared by multiple tests.

…so that the same host can be shared by multiple tests.
@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Test Results

311 tests  ±0   304 ✅  - 1   1m 42s ⏱️ -30s
  5 suites ±0     6 💤 ±0 
  5 files   ±0     1 ❌ +1 

For more details on these failures, see this check.

Results for commit a1729fd. ± Comparison against base commit 9c4076d.

This pull request removes 3 and adds 2 tests. Note that renamed tests count towards both.
,False)
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesKeyNameAsync (Hello
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesValueAsync (Invalid
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesKeyNameAsync (Hello
,False)
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesValueAsync (Invalid
,False)

♻️ This comment has been updated with latest results.

Copy link
Contributor

Copilot AI left a comment

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 refactors the E2E test infrastructure to allow sharing a single AdaptiveRemoteHost instance across multiple tests, improving test performance by avoiding repeated startup/shutdown cycles. The changes introduce a new hook-based setup system using Reqnroll's BeforeTestRun/BeforeScenario/AfterScenario hooks, and modify the test environment lifecycle to be more efficient.

Changes:

  • Introduced centralized test infrastructure setup through LoggerFactoryHooks and EnvironmentSetupHooks
  • Refactored SimulatedEnvironment to manage host lifecycle and allow host reuse across tests
  • Modified AdaptiveRemoteHost.Builder to support dynamic configuration updates
  • Updated test features to use declarative "Given the application is in the Ready phase" instead of explicit start/stop
  • Fixed SimulatedBroadlinkDevice authentication to properly reset encryption for re-authentication

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
SimulatedBroadlinkDevice.cs Fixed re-authentication bug by resetting encryption to default key before sending auth response
TestContextLoggerProvider.cs Made TestContext nullable and updated logger to handle null context gracefully
TestContextLoggerExtensions.cs Removed extension method (replaced by direct registration in hooks)
HostApplicationLoggerProvider.cs Changed visibility to public and simplified proxy attachment logic
SimulatedEnvironment.cs Refactored to manage host lifecycle with Start/Stop/EnsureStarted methods
ISimulatedEnvironment.cs Updated interface to expose host lifecycle management methods
AdaptiveRemoteHost.Builder.cs Refactored to accept logger dependencies via constructor and support mutable settings
UISteps.cs Removed trailing whitespace
StepsBase.cs Simplified to get host from Environment instead of managing its own host instance
SimulatedTiVoSteps.cs Changed logging from TestContext to ILogger
SimulatedBroadlinkSteps.cs Changed logging from TestContext to ILogger and renamed class
LogVerificationSteps.cs New step class for verifying log file contents
LogSteps.cs Removed (replaced by LogVerificationSteps)
HostSteps.cs Removed (replaced by AdptiveRemoteHostSteps)
LoggerFactoryHooks.cs New hook for registering logging infrastructure in DI container
EnvironmentSetupHooks.cs New hook for managing shared test environment lifecycle
DebugSteps.cs Added warning logging step for testing
AdptiveRemoteHostSteps.cs New step class for host lifecycle management
TiVoDevice.feature Simplified to use declarative host state management
StartupAndShutdown.feature Updated to check errors only instead of warnings
BroadlinkDevice.feature Simplified to use declarative host state management
AdaptiveRemote.EndToEndTests.Features.projitems Changed to glob pattern for including all .feature files
_Host.cshtml New Razor page for headless host

…wright host can take a long time to shut down. Because of the shared hosts, the next test could end up trying to use a host that is still in the process of shutting down.

Also, fail the startup/shutdown test if the process doesn't exit within the timeout, so we'll know if this happens on CI.
@jodavis
Copy link
Owner Author

jodavis commented Feb 19, 2026

Pushed a change to increase the shutdown timeout for the headless host. Sometimes it takes a long time, and that resulted in the TiVo test trying to use a host that was still in the process of shutting down.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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

Comments