Refactor environment/device creation and AdaptiveRemoteHost lifetime …#90
Refactor environment/device creation and AdaptiveRemoteHost lifetime …#90
Conversation
…so that the same host can be shared by multiple tests.
Test Results311 tests ±0 304 ✅ - 1 1m 42s ⏱️ -30s 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.♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
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 |
test/AdaptiveRemote.EndtoEndTests.TestServices/Logging/TestContextLoggerProvider.cs
Outdated
Show resolved
Hide resolved
test/AdaptiveRemote.EndToEndTests.Steps/AdptiveRemoteHostSteps.cs
Outdated
Show resolved
Hide resolved
test/AdaptiveRemote.EndtoEndTests.TestServices/Host/AdaptiveRemoteHost.Builder.cs
Show resolved
Hide resolved
…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.
|
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>
…so that the same host can be shared by multiple tests.