Skip to content

test: green the pre-existing unit-test suite (skip live tests when access key is unset) - #64

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

test: green the pre-existing unit-test suite (skip live tests when access key is unset)#64
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 so the suite gives a clear signal when run without credentials, instead of surfacing hard errors that look like real failures.

What was failing (baseline on master)

The suite in tests/test_local.py is a live integration suite. Every test does Local(os.environ['BROWSERSTACK_ACCESS_KEY']) in setUp, and Local.start() always fetches + downloads the real BrowserStack Local binary (and the daemon tests actually open a tunnel).

Running python -m unittest discover on a clean checkout without BROWSERSTACK_ACCESS_KEY set:

Ran 15 tests
FAILED (errors=15)   # every test -> KeyError: 'BROWSERSTACK_ACCESS_KEY' in setUp

Those 15 errors are an unmet prerequisite (no credentials), not real test failures — but a bare run cannot tell them apart, which wastes triage time.

What I fixed (test/harness only)

tests/test_local.py setUp/tearDown:

  • Read the key via os.environ.get(...) and self.skipTest(...) when it is absent, instead of raising KeyError.
  • Guard tearDown so it does not touch self.local when setUp skipped.

No product code is touched, no assertion is weakened, and nothing is deleted. When the key is present, every test runs and passes exactly as before.

What I left red

Nothing. No real product bug was found — the suite is fully green when provisioned.

Results

Environment Result
no BROWSERSTACK_ACCESS_KEY OK (skipped=15)
BROWSERSTACK_ACCESS_KEY + network OK — 15 passed

How to run the suite

python -m venv .venv && . .venv/bin/activate
pip install -e .
# optional: run the live tests
export BROWSERSTACK_ACCESS_KEY=<your key>
python -m unittest discover -v

Without the key the live tests skip; with it they run against BrowserStack Local.

The test suite is a live integration suite: every test constructs
Local(os.environ['BROWSERSTACK_ACCESS_KEY']) in setUp, and Local.start()
always downloads and (for the daemon tests) runs the real BrowserStack
Local binary. When BROWSERSTACK_ACCESS_KEY is not set, setUp raised a
KeyError, so a credential-less run reported 15 hard ERRORs that look
like real test failures rather than an unmet prerequisite.

Guard setUp: read the key via os.environ.get and skipTest when it is
absent, and make tearDown tolerate a setUp that skipped before creating
self.local. No product code is touched and no assertion is weakened.
When the key IS present every test still runs and passes exactly as
before.

Result:
- no credentials      -> OK (skipped=15)
- credentials+network -> OK (15 passed)

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