Skip to content

test: add local HTTP mock server for client-side command tests (#1160) - #310

Closed
Dor-bl wants to merge 7 commits into
mainfrom
claude/github-comment-verification-h9o9vq
Closed

Dor-bl wants to merge 7 commits into
mainfrom
claude/github-comment-verification-h9o9vq

Conversation

@Dor-bl

@Dor-bl Dor-bl commented Nov 20, 2026

Copy link
Copy Markdown
Owner
  • test: add local HTTP mock server for client-side command tests

  • test: tighten mock server routing and W3C capability assertions

  • test: replace HttpListener with loopback TcpListener in MockAppiumServer

  • test: assert disjoint W3C capability sets and close active clients on disposal

  • test: use WireMock.Net in MockAppiumServer

  • test: use JsonPartialMatcher in MockAppiumServer and remove unused ClearRecordedRequests

hoanle0126 and others added 7 commits November 4, 2026 09:15
…m#1160)

* test: add local HTTP mock server for client-side command tests

* test: tighten mock server routing and W3C capability assertions

* test: replace HttpListener with loopback TcpListener in MockAppiumServer

* test: assert disjoint W3C capability sets and close active clients on disposal

* test: use WireMock.Net in MockAppiumServer

* test: use JsonPartialMatcher in MockAppiumServer and remove unused ClearRecordedRequests
---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ppium#1149)

* test(android): cover AndroidCommandExecutionHelper.OpenNotifications

Verifies OpenNotifications issues a single ExecuteScript command for
mobile:openNotifications with an empty args array.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: extract FakeExecuteMethod into shared test helpers

Move the IExecuteMethod fake out of AndroidCommandExecutionHelperTests into
test/integration/helpers so other command-helper tests can reuse it. It now
records every executed command in order instead of only the last one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ppium#1143)

SimpleTouchActionTestCase and TouchByCoordinatesTestCase fail intermittently
on CI with StaleElementReferenceException: ActivateApp can return while the
ApiDemos list is still being redrawn, so the TextViews found right after it
are replaced before the actions run.

- Add PerformOnTextViews, which finds the TextViews again and retries the
  actions (up to 3 attempts) when they go stale.
- Share the wait for the TextView count to change between both tests;
  TouchByCoordinatesTestCase used a fixed Thread.Sleep(1000) instead.
- Pass a 5-second timeout to TerminateApp in TearDown so tearing down
  ApiDemos under emulator load does not fail on the default 500ms timeout.
The helper introduced in appium#1103 passed its argument straight to
Enumerable.ToList when the collection was neither a ReadOnlyCollection
nor an IList, so a finder returning null surfaced an
ArgumentNullException naming LINQ's internal "source" parameter instead
of the helper's own argument. Validate the argument up front so the
exception points at "collection".

Extends MobileByFactoryTest with the null case and the List-to-
ReadOnlyCollection conversion; the ReadOnlyCollection pass-through is
already covered by TizenAutomationDelegatesToMatchingFinder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JXt9AdcyCrYRXRAAZpgWBx
Copilot AI balanced review requested due to automatic review settings November 20, 2026 19:49
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 70ae3233-2e3f-4808-bb46-746a111cd45e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

🟡 Changes recommended

Changing SessionId after construction leaves the new-session response and DELETE route using the old ID while script routes use the new ID, causing script requests to return 404.

1 open issue
What changed in this PR

This PR adds device-free HTTP testing for the Appium .NET client using WireMock.Net, alongside targeted functional-test reliability improvements.

Changes:

  • Add a local mock server and tests for session creation, command routing, serialization, and responses.
  • Expand command-helper and collection tests, with explicit null validation.
  • Improve Android test synchronization and configure iOS tests to use the selected simulator.
File Description
test/​integration/​helpers/​MockAppiumServer.cs Add a WireMock-backed server with request recording and response stubs.
test/​integration/​helpers/​FakeExecuteMethod.cs Add a command-recording fake for device-free tests.
test/​integration/​helpers/​Caps.cs Support simulator selection through IOS_UDID.
test/​integration/​helpers/​AppsTest.cs Test inclusion and omission of the iOS UDID capability.
test/​integration/​Driver/​MockServerClientTests.cs Verify client HTTP requests and response handling.
test/​integration/​Common/​MobileByFactoryTest.cs Test collection wrapping and null handling.
test/​integration/​Appium.Net.Integration.Tests.csproj Add WireMock.Net and update the test SDK.
test/​integration/​Android/​Device/​Keys/​KeyboardTests.cs Wait for keyboard visibility before testing keyboard commands.
test/​integration/​Android/​AndroidCommandExecutionHelperTests.cs Verify notification command names and arguments.
test/​integration/​Android/​ActionsChainsTest.cs Retry stale elements and replace a fixed sleep with polling.
src/​Appium.Net/​Appium/​ReadOnlyCollectionExtensions.cs Explicitly reject null collections.
.github/​workflows/​functional-test.yml Install WebDriverAgent and pass the selected simulator UDID to tests.

Review effort: Balanced

private readonly WireMockServer _server;
private bool _disposed;

public string SessionId { get; set; } = "mock-session-id";

Dor-bl commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Closing: this PR targets this fork's main, which is behind appium/dotnet-client. Because of that it lists six commits that upstream has already merged (appium#1160, appium#1162, appium#1169, appium#1149, appium#1143, appium#1175), and GitHub took its title from appium#1160.

The only new commit is 8952c07 (fix: guard ReadOnlyCollectionExtensions.AsReadOnly against null). It will be opened against upstream main instead:
appium/dotnet-client@main...Dor-bl:dotnet-client:claude/github-comment-verification-h9o9vq

The branch is kept for that PR.


Generated by Claude Code

@Dor-bl Dor-bl closed this Nov 21, 2026
@Dor-bl
Dor-bl deleted the claude/github-comment-verification-h9o9vq branch November 24, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants