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
- 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. - CLI –
dotnet testfrom the repository root afterdotnet build.
Debugging tips
- Headed mode –
Headless = falseinCSTestingOptions. - Slow down –
await Browser!.SleepAsync(2000)before a failing step. - Assertions – Use NUnit
Assert.That(...)with values fromawait Browser.Locator(...).GetTextContentAsync(),await Browser.IsVisibleAsync(selector), etc. The browser API does not exposeassertThat. See Assertions. - Pause on failure – Inherit
CSTestingNUnitBrowserFixtureBaseand setCSTESTING_DEBUG=1orCSTESTING_PAUSE_ON_FAILURE=1(see repodocs/TAGS_AND_DEBUG.md). - DevTools – In headed mode, attach to the Chromium window.
Summary
| Topic | CSTesting .NET |
|---|---|
| Run tests | dotnet test |
| Filter by tag | dotnet test --filter "TestCategory=smoke" with [CSTestingTag("smoke")] or [Category("smoke")] |
| Headless | new CSTestingOptions { Headless = true } (typical default) |
| Headed | Headless = false |
| From IDE | NUnit Test Explorer, debug as usual |