Skip to content

Add NUnit + Reqnroll + Playwright BrowserStack SDK sample#2

Merged
karanshah-browserstack merged 8 commits into
mainfrom
add-nunit-reqnroll-playwright-sample
Jul 15, 2026
Merged

Add NUnit + Reqnroll + Playwright BrowserStack SDK sample#2
karanshah-browserstack merged 8 commits into
mainfrom
add-nunit-reqnroll-playwright-sample

Conversation

@saraswati-padmawar

@saraswati-padmawar saraswati-padmawar commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Populates this customer-facing sample repo (previously skeleton: README + CODEOWNERS + Semgrep only) with a working NUnit + Reqnroll + Playwright (C#) sample driven by the BrowserStack .NET SDK.

What's included

  • Features/Sample.feature + StepDefinitions/SampleSteps.cs — public bstackdemo.com add-to-cart scenario
  • Features/LocalSample.feature + StepDefinitions/LocalSampleSteps.cs — BrowserStack Local scenario (bs-local.com:45454)
  • Hooks/PlaywrightHooks.cs — creates IPage per scenario (SDK routes Chromium.LaunchAsync())
  • browserstack.yml — credentials, platforms, Local toggle, framework: nunit
  • .sln / .csproj (Reqnroll.NUnit + NUnit + Microsoft.Playwright.NUnit + BrowserStack.TestAdapter), .gitignore, sanity-workflow.yml, README

References

  • Direct adaptation of browserstack/xunit-reqnroll-playwright-browserstack, swapping the xUnit runner for NUnit (packages + Assert.That assertions + framework: nunit)
  • NUnit package set aligned with browserstack/csharp-playwright-browserstack
  • Follows the standardized Automate sample template (Confluence: SDK Sample Repo Generator, R1–R4)

Verified on BrowserStack ✅

Built and ran both scenarios end-to-end against BrowserStack Automate (.NET 8, arm64), passing on the configured platforms (Windows 11/chrome, OS X Ventura/playwright-webkit)
Reqnroll generated the NUnit tests from the .feature files. Project: BrowserStack Samples.

Note from verification: the SDK's auto-generated patch references the Microsoft.Playwright.NUnit namespace, so Microsoft.Playwright.NUnit is required in the .csproj (without it dotnet build fails CS0234) — added in this PR.

🤖 Generated with Claude Code

C# sample mirroring xunit-reqnroll-playwright-browserstack, swapped to the NUnit
runner. Sample.feature (bstackdemo add-to-cart) + LocalSample.feature (BrowserStack
Local via bs-local.com:45454), step definitions with NUnit assertions, Playwright
hooks, browserstack.yml (framework: nunit), .sln/.csproj, sanity workflow, and README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@saraswati-padmawar saraswati-padmawar requested a review from a team as a code owner June 30, 2026 08:17
saraswati-padmawar and others added 2 commits June 30, 2026 15:44
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The BrowserStack .NET SDK's auto-generated BrowserStackPatch.cs references the
Microsoft.Playwright.NUnit namespace; without the package the build fails with
CS0234 'NUnit does not exist in namespace Microsoft.Playwright'. The NUnit+PW
reference repo (csharp-playwright-browserstack) includes it too.

Verified: 2/2 platforms (Win11/chrome, OSX/webkit) pass real BrowserStack sessions
on .NET 8 / arm64.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rohannagariya1
Rohannagariya1 previously approved these changes Jul 1, 2026

@Rohannagariya1 Rohannagariya1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅ — solid NUnit/Reqnroll adaptation, both scenarios verified. Approving.

A few low-risk, optional cleanups (non-blocking):

  • System.Net.Http 4.3.4 and System.Text.RegularExpressions 4.3.1 in the .csproj are in-box on net8.0 and unnecessary — safe to drop (and they're the kind of legacy refs Semgrep/dependabot tend to flag).
  • browserstack.yml is missing testReporting: true (+ the reporting comment block) that both Node siblings include — minor cross-sample consistency.
  • The workflow's "completed" step calls checks.create again rather than updating the in-progress run, so you get one stuck in_progress + one completed check. Copied from the xunit reference, so low priority.
  • [id="\31 "] works but is inconsistent with the plain [id="1"] attribute selector used in the JS samples — purely cosmetic.

osho-20
osho-20 previously approved these changes Jul 7, 2026
The Local scenario navigates to bs-local.com:45454 and asserts the page title
contains 'BrowserStack Local', but the README never told users to serve anything
on that port -- so following it verbatim failed. Document serving a matching local
page (and how to point at your own app), and describe the tunnel routing accurately.
@saraswati-padmawar saraswati-padmawar dismissed stale reviews from osho-20 and Rohannagariya1 via 5d67d9f July 9, 2026 09:39
Comment thread .github/workflows/sanity-workflow.yml Fixed
Comment thread .github/workflows/sanity-workflow.yml Fixed
@saraswati-padmawar

Copy link
Copy Markdown
Collaborator Author

Claude Code PR Review

PR: #2Head: 5d67d9fReviewers: stack:code-reviewer

Summary

Populates this previously-skeleton sample repo with a working NUnit + Reqnroll + Playwright (C#) sample driven by the BrowserStack .NET SDK — a faithful conversion of the xunit-reqnroll-playwright-browserstack sibling. Verified green on BrowserStack (public + Local scenarios, Windows/chrome + macOS/webkit).

Review Table

Priority Category Check Status Notes
High Security No hardcoded secrets or credentials Pass Placeholders only; org secrets in workflow
High Security Authentication/authorization checks present N/A Sample test project
High Security Input validation and sanitization N/A
High Security No IDOR — resource ownership validated N/A
High Security No SQL injection (parameterized queries) N/A No DB
High Correctness Logic is correct, handles edge cases Pass NUnit Assert.That conversions correct; verified green
High Correctness Error handling is explicit, no swallowed exceptions Pass Hooks dispose browser/playwright
High Correctness No race conditions or concurrency issues Pass Per-scenario page via ScenarioContext
Medium Testing New code has corresponding tests Pass The sample is the test
Medium Testing Error paths and edge cases tested N/A Sample scope
Medium Testing Existing tests still pass (no regressions) Pass Fresh repo
Medium Performance No N+1 queries or unbounded data fetching N/A
Medium Performance Long-running tasks use background jobs N/A
Medium Quality Follows existing codebase patterns Pass Faithful mirror of the xUnit sibling
Medium Quality Changes are focused (single concern) Pass
Low Quality Meaningful names, no dead code Pass
Low Quality Comments explain why, not what Pass
Low Quality No unnecessary dependencies added Pass Microsoft.Playwright.NUnit required by SDK patch; see below re legacy pkgs

Findings

No correctness or security issues. Workflow has no injection risk — the untrusted commit_sha input is passed via env: and read as process.env, never interpolated into a run: shell or the github-script body; github-script is pinned to a full SHA; least-privilege permissions.

  • File: NunitCsharpReqnrollPlaywrightBrowserstack.Tests/NunitCsharpReqnrollPlaywrightBrowserstack.Tests.csproj:14

  • Severity: Low (inherited from the xUnit sibling)

  • Reviewer: stack:code-reviewer

  • Issue: BrowserStack.TestAdapter 0.*, Microsoft.Playwright *, Microsoft.Playwright.NUnit * use open wildcards → non-reproducible builds; a future Playwright major could break the sample with no code change.

  • Suggestion: pin the Playwright packages to a floating-minor (e.g. 1.*) for a customer-facing sample.

  • File: NunitCsharpReqnrollPlaywrightBrowserstack.Tests/NunitCsharpReqnrollPlaywrightBrowserstack.Tests.csproj:19

  • Severity: Low (inherited)

  • Reviewer: stack:code-reviewer

  • Issue: System.Net.Http 4.3.4 and System.Text.RegularExpressions 4.3.1 are .NET Framework-era packages, unnecessary on net8.0.

  • Suggestion: drop them (also worth fixing in the xUnit sibling).


Verdict: PASS — the cleanest of the three: correct NUnit conversion, no security/injection issues, and verified green on BrowserStack. Only inherited Low-severity dependency hygiene remains.

Review run via the BrowserStack AI harness stack:pr-review methodology (harness not installed in the run environment → independent stack:code-reviewer fallback).

Semgrep's supply-chain rule (action not pinned to a full commit SHA) blocks on
unpinned tag refs like actions/checkout@v4. Pin all actions to SHAs with a
version comment, matching the repo's Semgrep.yml. Also modernizes v3->v4.
Comment thread NunitCsharpReqnrollPlaywrightBrowserstack.Tests/browserstack.yml Outdated
Comment thread NunitCsharpReqnrollPlaywrightBrowserstack.Tests/browserstack.yml
Per review: the source tag tracks the onboarding funnel as <repo>:<label>:<version>.
Align with csharp-playwright-browserstack (and the SDK Sample Repo Generator spec):
use the full repo name and the 'sample-sdk' label instead of the stale 'sample-master'
inherited from the xUnit sibling.
Reviewer specified the onboarding-funnel source tag as <repo>:main:v1.0 -- the
middle segment is the branch the sample lives on (main), not the 'sample-sdk' label.
…ecklist

The canonical format (Confluence ENG/4080468210) is {f/w-name}:sample-{branch-name}:v{version}.
The sample lives on main, so the branch segment is sample-main (keeps the sample- prefix).
@karanshah-browserstack karanshah-browserstack merged commit 1087ebd into main Jul 15, 2026
5 checks passed
@karanshah-browserstack karanshah-browserstack deleted the add-nunit-reqnroll-playwright-sample branch July 15, 2026 07:29
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.

5 participants