Running and debugging tests

Introduction

CSTesting for .NET (C:\CSTesting-DotNet) is a library used from NUnit tests. You run tests with the normal .NET CLI: dotnet test. There is no separate Java-style CSTestingRunner. Create the browser in [SetUp] (or inside each test), and optionally inherit CSTestingNUnitBrowserFixtureBase so the browser is closed after each test and pause-on-failure works.

By default, use new CSTestingOptions { Headless = true } with CreateBrowserAsync. Set Headless = false to see the Chromium window while debugging.

Running with dotnet test

From the solution or test project folder (see README.md in C:\CSTesting-DotNet):

dotnet build
playwright install chromium
dotnet test

Filter by NUnit categories / CSTesting tags (same ideas as Node):

dotnet test --filter "TestCategory=smoke"

Run one test fixture or method using NUnit filter expressions as usual.

See NUnit & lifecycle for [TestFixture], [SetUp], CSTestingTag, and environment variables for pause-on-failure.

Headed browser

Pass options when creating the browser:

Browser = await CreateBrowserAsync(new CSTestingOptions { Headless = false });

Or toggle per debug session via your own helper or launchSettings.

Running from the IDE

  1. Visual Studio / Rider / VS Code – Use Test Explorer to run or debug NUnit tests; breakpoints in [Test] methods and in CSTesting sources work as with any async test.
  2. CLIdotnet test from the repository root after dotnet build.

Debugging tips

  1. Headed modeHeadless = false in CSTestingOptions.
  2. Slow downawait Browser!.SleepAsync(2000) before a failing step.
  3. Assertions – Use NUnit Assert.That(...) with values from await Browser.Locator(...).GetTextContentAsync(), await Browser.IsVisibleAsync(selector), etc. The browser API does not expose assertThat. See Assertions.
  4. Pause on failure – Inherit CSTestingNUnitBrowserFixtureBase and set CSTESTING_DEBUG=1 or CSTESTING_PAUSE_ON_FAILURE=1 (see repo docs/TAGS_AND_DEBUG.md).
  5. DevTools – In headed mode, attach to the Chromium window.

Summary

TopicCSTesting .NET
Run testsdotnet test
Filter by tagdotnet test --filter "TestCategory=smoke" with [CSTestingTag("smoke")] or [Category("smoke")]
Headlessnew CSTestingOptions { Headless = true } (typical default)
HeadedHeadless = false
From IDENUnit Test Explorer, debug as usual