[dotnet] [test] Introduce fake BiDi transport#17627
Conversation
Review Summary by QodoIntroduce fake BiDi transport and refactor to factory-based API
WalkthroughsDescription• Introduce FakeTransport for deterministic unit testing without real browser • Change UseTransport API to accept factory function instead of instance • Move timeout, cancellation, and disposal tests to new SessionUnitTests • Add comprehensive unit tests for command sequencing and error handling Diagramflowchart LR
A["BiDiOptionsBuilder"] -->|"UseTransport factory"| B["ITransport instance"]
C["FakeTransport"] -->|"implements"| B
D["SessionTests"] -->|"moves tests to"| E["SessionUnitTests"]
E -->|"uses"| C
F["Unit tests"] -->|"test timeout/cancellation"| E
File Changes1. dotnet/src/webdriver/BiDi/BiDiOptionsBuilder.cs
|
Code Review by Qodo
1.
|
|
Code review by qodo was updated up to the latest commit 1a5c307 |
And use it for some testing scenarios. Might be not elegant api, but it is OK for now.
Also changed bidi options to factory instead of provided instance. It resolves ownership problems.
💥 What does this PR do?
This pull request refactors and improves the BiDi (Bidirectional) WebDriver test suite by introducing a new in-process fake transport for more deterministic and isolated unit testing. It also moves several tests from integration-style tests to new unit tests, and updates the transport configuration API for greater flexibility.
Testing improvements
FakeTransportclass that implementsITransportfor in-process, controllable, and deterministic unit testing of BiDi functionality without requiring a real browser or network connection. (dotnet/test/webdriver/BiDi/FakeTransport.cs)SessionTeststo a newSessionUnitTestsclass, now usingFakeTransportto test command timeouts, cancellation, disposal, error handling, and command ID sequencing in isolation. (dotnet/test/webdriver/BiDi/SessionUnitTests.cs)SessionTests, as these are now covered in the new unit tests. (dotnet/test/webdriver/BiDi/Session/SessionTests.cs)SessionTests, as it is now covered in the unit tests. (dotnet/test/webdriver/BiDi/Session/SessionTests.cs)API improvements
UseTransportmethod inBiDiOptionsBuilderto accept a factory function for creatingITransportinstances, improving flexibility and ensuring correct ownership and disposal of transports. (dotnet/src/webdriver/BiDi/BiDiOptionsBuilder.cs)🤖 AI assistance
🔄 Types of changes