Skip to content

test: fix pre-existing unit-test failures (green the suite) - #62

Draft
07souravkunda wants to merge 1 commit into
masterfrom
chore/green-unit-tests
Draft

test: fix pre-existing unit-test failures (green the suite)#62
07souravkunda wants to merge 1 commit into
masterfrom
chore/green-unit-tests

Conversation

@07souravkunda

Copy link
Copy Markdown
Collaborator

What this does

Greens the pre-existing unit-test baseline. On a clean master checkout the suite had 11 failing tests (12 passing / 23 total), all caused by test rot or a test-side network dependency — no product bugs. This lets future contributors trust the suite as a clean baseline.

What was failing & why

LocalTests — 6 failures (stale assertion / test rot)
TestWorksForBinaryPath, TestWorksWithBooleanOptions, TestWorksWithValueOptions, TestWorksWithCustomOptions, TestCallsFallbackOnFailure, TestKillsTunnel.

Each verified addBinaryPath("<path>", "", ...) — hardcoding the access-key argument as "". The binding actually forwards the real access key ("dummyKey" in these tests), because it is required as the auth_token for the binary-endpoint lookup. The production call is correct; the assertion was stale. Updated the expected argument to "dummyKey".

BrowserStackTunnelTests — 5 failures (network dependency)
TestBinaryPathIsSet, TestBinaryPathOnNull, TestBinaryPathOnEmpty, TestBinaryPathOnFallback, TestBinaryPathOnNoMoreFallback.

These use a real tunnel subclass to test binary-path resolution and fallback ordering. The first addBinaryPath(...) call eagerly performs a live HTTP POST to the endpoint API, which returns 401 Unauthorized with no/empty credentials — so the tests failed in any offline or credential-less environment (e.g. CI). Added a test-only override of the network-fetch method in the test TunnelClass so the tests exercise the real path-resolution and fallback logic hermetically (no network).

Fixes applied (scoped)

  • BrowserStackLocal Unit Tests/LocalTests.cs — corrected the access-key argument in 6 mock verifications.
  • BrowserStackLocal Unit Tests/BrowserStackTunnelTests.cs — added a test-only override that stubs the network fetch.
  • BrowserStackLocal/BrowserStackTunnel.cs — the only production change: made the network-fetch method protected virtual to create the test seam. No behavior change (no production subclass overrides it).

Left red

None — no test was masking a real product bug, so nothing was left failing.

How to run the suite

dotnet build "BrowserStackLocal/BrowserStackLocal/BrowserStackLocal.csproj" -c Debug
dotnet test  "BrowserStackLocal/BrowserStackLocal Unit Tests/BrowserStackLocal Unit Tests.csproj" -c Debug

Result after this PR: Passed: 23, Failed: 0 (runs with no network access).

🤖 Generated with Claude Code

The unit suite had 11 pre-existing failures on a clean checkout, all due
to test rot / a network dependency rather than product bugs:

- LocalTests (6): the addBinaryPath(...) mock verifications hardcoded the
  access-key argument as "" while the binding correctly forwards the real
  access key (needed as auth_token for the endpoint lookup). Updated the
  expected argument to match current behavior.

- BrowserStackTunnelTests (5): the binary-path / fallback tests use a real
  tunnel subclass, so addBinaryPath's first call made a live HTTP POST to
  the endpoint API and failed with 401 in any offline / no-credential
  environment. Added a test-only override of the network fetch so these
  tests exercise the real path-resolution and fallback logic hermetically.
  The only production change is making that fetch method protected virtual
  to create the seam; behavior is unchanged.

Suite is now green (23/23) and runs with no network access.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.

1 participant