Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs(dotnet): add a note about Xunit.v3 (#36978)
Max Schmittfa8a326eee0f
diff --git a/docs/src/intro-csharp.md b/docs/src/intro-csharp.mdindex 9919d2d9a2..f48722c070 100644--- a/docs/src/intro-csharp.md+++ b/docs/src/intro-csharp.md@@ -18,6 +18,7 @@ You can choose to use MSTest, NUnit, or xUnit [base classes](./test-runners.md){label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -43,6 +44,14 @@ dotnet new xunit -n PlaywrightTestscd PlaywrightTests```+</TabItem>+<TabItem value="xunit-v3">++```bash+dotnet new xunit -n PlaywrightTests+cd PlaywrightTests+```+</TabItem></Tabs>@@ -55,6 +64,7 @@ cd PlaywrightTests{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -77,6 +87,13 @@ dotnet add package Microsoft.Playwright.MSTestdotnet add package Microsoft.Playwright.Xunit```+</TabItem>+<TabItem value="xunit-v3">++```bash+dotnet add package Microsoft.Playwright.Xunit.v3+```+</TabItem></Tabs>@@ -105,6 +122,7 @@ Edit the `UnitTest1.cs` file with the code below to create an example end-to-end{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -191,6 +209,40 @@ using Microsoft.Playwright.Xunit;namespace PlaywrightTests;+public class UnitTest1: PageTest+{+ [Fact]+ public async Task HasTitle()+ {+ await Page.GotoAsync("https://playwright.dev");++ // Expect a title "to contain" a substring.+ await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));+ }++ [Fact]+ public async Task GetStartedLink()+ {+ await Page.GotoAsync("https://playwright.dev");++ // Click the get started link.+ await Page.GetByRole(AriaRole.Link, new() { Name = "Get started" }).ClickAsync();++ // Expects page to have a heading with the name of Installation.+ await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Installation" })).ToBeVisibleAsync();+ }+}+```+</TabItem>+<TabItem value="xunit-v3">++```csharp title="UnitTest1.cs"+using System.Text.RegularExpressions;+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;++namespace PlaywrightTests;+public class UnitTest1: PageTest{[Fact]@@ -243,4 +295,4 @@ See our doc on [Running and Debugging Tests](./running-tests.md) to learn more a- [Generate tests with Codegen](./codegen-intro.md)- [See a trace of your tests](./trace-viewer-intro.md)- [Run tests on CI](./ci-intro.md)-- [Learn more about the MSTest, NUnit, and xUnit base classes](./test-runners.md)+- [Learn more about the MSTest, NUnit, xUnit and xUnit v3 base classes](./test-runners.md)diff --git a/docs/src/languages.md b/docs/src/languages.mdindex c8e8c8ac26..1ddc36469e 100644--- a/docs/src/languages.md+++ b/docs/src/languages.md@@ -30,7 +30,7 @@ You can choose any testing framework such as JUnit or TestNG based on your proje## .NET-Playwright for .NET comes with MSTest, NUnit, and xUnit [base classes](https://playwright.dev/dotnet/docs/test-runners) for writing end-to-end tests.+Playwright for .NET comes with MSTest, NUnit, xUnit, and xUnit v3 [base classes](https://playwright.dev/dotnet/docs/test-runners) for writing end-to-end tests.* [Documentation](https://playwright.dev/dotnet/docs/intro)* [GitHub repo](https://github.com/microsoft/playwright-dotnet)diff --git a/docs/src/library-csharp.md b/docs/src/library-csharp.mdindex 2bba6a6683..0efc5b7035 100644--- a/docs/src/library-csharp.md+++ b/docs/src/library-csharp.md@@ -5,7 +5,7 @@ title: "Getting started - Library"## Introduction-Playwright can either be used with the [MSTest, NUnit, or xUnit base classes](./test-runners.md) or as a Playwright Library (this guide). If you are working on an application that utilizes Playwright capabilities or you are using Playwright with another test runner, read on.+Playwright can either be used with the [MSTest, NUnit, xUnit, or xUnit v3 base classes](./test-runners.md) or as a Playwright Library (this guide). If you are working on an application that utilizes Playwright capabilities or you are using Playwright with another test runner, read on.## Usagediff --git a/docs/src/running-tests-csharp.md b/docs/src/running-tests-csharp.mdindex 0b2fed27b3..1711355410 100644--- a/docs/src/running-tests-csharp.md+++ b/docs/src/running-tests-csharp.md@@ -114,6 +114,7 @@ dotnet test --filter "Name~GetStartedLink"{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -142,6 +143,19 @@ See [here](https://xunit.net/docs/running-tests-in-parallel.html) for more inforWe recommend xUnit 2.8+ which uses the [`conservative` parallelism algorithm](https://xunit.net/docs/running-tests-in-parallel.html#algorithms) by default.:::+</TabItem>+<TabItem value="xunit-v3">++```bash+dotnet test -- xUnit.MaxParallelThreads=5+```++See [here](https://xunit.net/docs/running-tests-in-parallel.html) for more information to run tests in parallel with xUnit v3.++:::note+xUnit v3 uses the [`conservative` parallelism algorithm](https://xunit.net/docs/running-tests-in-parallel.html#algorithms) by default.+:::+</TabItem></Tabs>@@ -173,4 +187,4 @@ Check out our [debugging guide](./debug.md) to learn more about the [Playwright- [Generate tests with Codegen](./codegen-intro.md)- [See a trace of your tests](./trace-viewer-intro.md)- [Run tests on CI](./ci-intro.md)-- [Learn more about the MSTest and NUnit base classes](./test-runners.md)+- [Learn more about the MSTest, NUnit, xUnit and xUnit v3 base classes](./test-runners.md)diff --git a/docs/src/test-assertions-csharp-java-python.md b/docs/src/test-assertions-csharp-java-python.mdindex 07f66d3192..114de1624a 100644--- a/docs/src/test-assertions-csharp-java-python.md+++ b/docs/src/test-assertions-csharp-java-python.md@@ -84,6 +84,7 @@ expect.set_options(timeout=10_000){label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -139,6 +140,24 @@ using Microsoft.Playwright.Xunit;namespace PlaywrightTests;+public class UnitTest1: PageTest+{+ UnitTest1()+ {+ SetDefaultExpectTimeout(10_000);+ }+ // ...+}+```+</TabItem>+<TabItem value="xunit-v3">++```csharp title="UnitTest1.cs"+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;++namespace PlaywrightTests;+public class UnitTest1: PageTest{UnitTest1()diff --git a/docs/src/test-runners-csharp.md b/docs/src/test-runners-csharp.mdindex baea64bbdb..f193d73619 100644--- a/docs/src/test-runners-csharp.md+++ b/docs/src/test-runners-csharp.md@@ -5,7 +5,7 @@ title: "Test Runners"## Introduction-While Playwright for .NET isn't tied to a particular test runner or testing framework, in our experience the easiest way of getting started is by using the base classes we provide for MSTest, NUnit, or xUnit. These classes support running tests on multiple browser engines, adjusting launch/context options and getting a [Page]/[BrowserContext] instance per test out of the box.+While Playwright for .NET isn't tied to a particular test runner or testing framework, in our experience the easiest way of getting started is by using the base classes we provide for MSTest, NUnit, xUnit, or xUnit v3. These classes support running tests on multiple browser engines, adjusting launch/context options and getting a [Page]/[BrowserContext] instance per test out of the box.Playwright and Browser instances will be reused between tests for better performance. Werecommend running each test case in a new BrowserContext, this way browser state will be@@ -18,6 +18,7 @@ isolated between the tests.{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -34,6 +35,11 @@ Playwright provides base classes to write tests with MSTest via the [`Microsoft.Playwright provides base classes to write tests with xUnit via the [`Microsoft.Playwright.Xunit`](https://www.nuget.org/packages/Microsoft.Playwright.Xunit) package.+</TabItem>+<TabItem value="xunit-v3">++Playwright provides base classes to write tests with xUnit v3 via the [`Microsoft.Playwright.Xunit.v3`](https://www.nuget.org/packages/Microsoft.Playwright.Xunit.v3) package.+</TabItem></Tabs>@@ -48,6 +54,7 @@ Check out the [installation guide](./intro.md) to get started.{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -85,6 +92,20 @@ dotnet test -- xUnit.MaxParallelThreads=5We recommend xUnit 2.8+ which uses the [`conservative` parallelism algorithm](https://xunit.net/docs/running-tests-in-parallel.html#algorithms) by default.:::+</TabItem>+<TabItem value="xunit-v3">++By default xUnit v3 will run all classes in parallel, while running tests inside each class sequentially.+It will create by default as many processes as there are cores on the system. You can adjust this behavior by using the following CLI parameter or using a `.runsettings` file, see below.++```bash+dotnet test -- xUnit.MaxParallelThreads=5+```++:::note+xUnit v3 uses the [`conservative` parallelism algorithm](https://xunit.net/docs/running-tests-in-parallel.html#algorithms) by default.+:::+</TabItem></Tabs>@@ -98,6 +119,7 @@ We recommend xUnit 2.8+ which uses the [`conservative` parallelism algorithm](ht{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -211,6 +233,41 @@ public class UnitTest1 : PageTest}```+</TabItem>+<TabItem value="xunit-v3">++To customize context options, you can override the `ContextOptions` method of your test class derived from `Microsoft.Playwright.Xunit.v3.PageTest` or `Microsoft.Playwright.Xunit.v3.ContextTest`. See the following example:++```csharp+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;++namespace PlaywrightTests;++public class UnitTest1 : PageTest+{+ [Fact]+ public async Task TestWithCustomContextOptions()+ {+ // The following Page (and BrowserContext) instance has the custom colorScheme, viewport and baseURL set:+ await Page.GotoAsync("/login");+ }+ public override BrowserNewContextOptions ContextOptions()+ {+ return new BrowserNewContextOptions()+ {+ ColorScheme = ColorScheme.Light,+ ViewportSize = new()+ {+ Width = 1920,+ Height = 1080+ },+ BaseURL = "https://github.com",+ };+ }+}+```+</TabItem></Tabs>@@ -252,6 +309,7 @@ When running tests from Visual Studio, you can take advantage of the `.runsettin{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -322,6 +380,36 @@ For example, to specify the number of workers, you can use `MSTest.Parallelize.WFor example, to specify the number of workers, you can use `xUnit.MaxParallelThreads`. You can also enable `DEBUG` logs using `RunConfiguration.EnvironmentVariables`.+```xml+<?xml version="1.0" encoding="utf-8"?>+<RunSettings>+ <!-- See https://xunit.net/docs/runsettings -->+ <xUnit>+ <MaxParallelThreads>1</MaxParallelThreads>+ </xUnit>+ <!-- General run configuration -->+ <RunConfiguration>+ <EnvironmentVariables>+ <!-- For debugging selectors, it's recommend to set the following environment variable -->+ <DEBUG>pw:api</DEBUG>+ </EnvironmentVariables>+ </RunConfiguration>+ <!-- Playwright -->+ <Playwright>+ <BrowserName>chromium</BrowserName>+ <ExpectTimeout>5000</ExpectTimeout>+ <LaunchOptions>+ <Headless>false</Headless>+ <Channel>msedge</Channel>+ </LaunchOptions>+ </Playwright>+</RunSettings>+```+</TabItem>+<TabItem value="xunit-v3">++For example, to specify the number of workers, you can use `xUnit.MaxParallelThreads`. You can also enable `DEBUG` logs using `RunConfiguration.EnvironmentVariables`.+```xml<?xml version="1.0" encoding="utf-8"?><RunSettings>@@ -359,6 +447,7 @@ For example, to specify the number of workers, you can use `xUnit.MaxParallelThr{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -375,6 +464,11 @@ There are a few base classes available to you in `Microsoft.Playwright.MSTest` nThere are a few base classes available to you in `Microsoft.Playwright.Xunit` namespace:+</TabItem>+<TabItem value="xunit-v3">++There are a few base classes available to you in `Microsoft.Playwright.Xunit.v3` namespace:+</TabItem></Tabs>diff --git a/docs/src/trace-viewer-intro-csharp.md b/docs/src/trace-viewer-intro-csharp.mdindex a3c463c5a5..885a92eab2 100644--- a/docs/src/trace-viewer-intro-csharp.md+++ b/docs/src/trace-viewer-intro-csharp.md@@ -23,6 +23,7 @@ Traces can be recorded using the [`property: BrowserContext.tracing`] API as fol{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -160,6 +161,69 @@ public class UnitTest1 : PageTest}}+public class WithTestNameAttribute : BeforeAfterTestAttribute+{+ public static string CurrentTestName = string.Empty;+ public static string CurrentClassName = string.Empty;++ public override void Before(MethodInfo methodInfo)+ {+ CurrentTestName = methodInfo.Name;+ CurrentClassName = methodInfo.DeclaringType!.Name;+ }++ public override void After(MethodInfo methodInfo)+ {+ }+}+```+</TabItem>+<TabItem value="xunit-v3">++```csharp+using System.Reflection;+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;+using Xunit.Sdk;++namespace PlaywrightTests;++[WithTestName]+public class UnitTest1 : PageTest+{+ public override async Task InitializeAsync()+ {+ await base.InitializeAsync().ConfigureAwait(false);+ await Context.Tracing.StartAsync(new()+ {+ Title = $"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}",+ Screenshots = true,+ Snapshots = true,+ Sources = true+ });+ }++ public override async Task DisposeAsync()+ {+ await Context.Tracing.StopAsync(new()+ {+ Path = Path.Combine(+ Environment.CurrentDirectory,+ "playwright-traces",+ $"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}.zip"+ )+ });+ await base.DisposeAsync().ConfigureAwait(false);+ }++ [Fact]+ public async Task GetStartedLink()+ {+ // ...+ await Page.GotoAsync("https://playwright.dev/dotnet/docs/intro");+ }+}+public class WithTestNameAttribute : BeforeAfterTestAttribute{public static string CurrentTestName = string.Empty;@@ -198,4 +262,4 @@ Check out our detailed guide on [Trace Viewer](/trace-viewer.md) to learn more a## What's next- [Run tests on CI with GitHub Actions](/ci-intro.md)-- [Learn more about the MSTest, NUnit, and xUnit base classes](./test-runners.md)+- [Learn more about the MSTest, NUnit, xUnit, and xUnit v3 base classes](./test-runners.md)diff --git a/docs/src/trace-viewer.md b/docs/src/trace-viewer.mdindex 52d772a0ca..c597c16f6e 100644--- a/docs/src/trace-viewer.md+++ b/docs/src/trace-viewer.md@@ -216,6 +216,7 @@ Traces can be recorded using the [`property: BrowserContext.tracing`] API as fol{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -374,6 +375,70 @@ public class WithTestNameAttribute : BeforeAfterTestAttribute}```+</TabItem>+<TabItem value="xunit-v3">++```csharp+using System.Reflection;+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;+using Xunit.Sdk;++namespace PlaywrightTests;++[WithTestName]+public class UnitTest1 : PageTest+{+ public override async Task InitializeAsync()+ {+ await base.InitializeAsync().ConfigureAwait(false);+ await Context.Tracing.StartAsync(new()+ {+ Title = $"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}",+ Screenshots = true,+ Snapshots = true,+ Sources = true+ });+ }++ public override async Task DisposeAsync()+ {+ await Context.Tracing.StopAsync(new()+ {+ Path = Path.Combine(+ Environment.CurrentDirectory,+ "playwright-traces",+ $"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}.zip"+ )+ });+ await base.DisposeAsync().ConfigureAwait(false);+ }++ [Fact]+ public async Task GetStartedLink()+ {+ // ...+ await Page.GotoAsync("https://playwright.dev/dotnet/docs/intro");+ }+}++public class WithTestNameAttribute : BeforeAfterTestAttribute+{+ public static string CurrentTestName = string.Empty;+ public static string CurrentClassName = string.Empty;++ public override void Before(MethodInfo methodInfo)+ {+ CurrentTestName = methodInfo.Name;+ CurrentClassName = methodInfo.DeclaringType!.Name;+ }++ public override void After(MethodInfo methodInfo)+ {+ }+}+```+</TabItem></Tabs>@@ -392,6 +457,7 @@ Setup your tests to record a trace only when the test fails:{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -550,6 +616,70 @@ public class WithTestNameAttribute : BeforeAfterTestAttribute}```+</TabItem>+<TabItem value="xunit-v3">++```csharp+using System.Reflection;+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;+using Xunit.Sdk;++namespace PlaywrightTests;++[WithTestName]+public class UnitTest1 : PageTest+{+ public override async Task InitializeAsync()+ {+ await base.InitializeAsync().ConfigureAwait(false);+ await Context.Tracing.StartAsync(new()+ {+ Title = $"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}",+ Screenshots = true,+ Snapshots = true,+ Sources = true+ });+ }++ public override async Task DisposeAsync()+ {+ await Context.Tracing.StopAsync(new()+ {+ Path = !TestOk ? Path.Combine(+ Environment.CurrentDirectory,+ "playwright-traces",+ $"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}.zip"+ ) : null+ });+ await base.DisposeAsync().ConfigureAwait(false);+ }++ [Fact]+ public async Task GetStartedLink()+ {+ // ...+ await Page.GotoAsync("https://playwright.dev/dotnet/docs/intro");+ }+}++public class WithTestNameAttribute : BeforeAfterTestAttribute+{+ public static string CurrentTestName = string.Empty;+ public static string CurrentClassName = string.Empty;++ public override void Before(MethodInfo methodInfo)+ {+ CurrentTestName = methodInfo.Name;+ CurrentClassName = methodInfo.DeclaringType!.Name;+ }++ public override void After(MethodInfo methodInfo)+ {+ }+}+```+</TabItem></Tabs>diff --git a/docs/src/writing-tests-csharp.md b/docs/src/writing-tests-csharp.mdindex 2f3873159a..f72d6e5a3d 100644--- a/docs/src/writing-tests-csharp.md+++ b/docs/src/writing-tests-csharp.md@@ -40,6 +40,7 @@ Take a look at the following example to see how to write a test.{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -128,6 +129,40 @@ using Microsoft.Playwright.Xunit;namespace PlaywrightTests;+public class UnitTest1: PageTest+{+ [Fact]+ public async Task HasTitle()+ {+ await Page.GotoAsync("https://playwright.dev");++ // Expect a title "to contain" a substring.+ await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));+ }++ [Fact]+ public async Task GetStartedLink()+ {+ await Page.GotoAsync("https://playwright.dev");++ // Click the get started link.+ await Page.GetByRole(AriaRole.Link, new() { Name = "Get started" }).ClickAsync();++ // Expects page to have a heading with the name of Installation.+ await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Installation" })).ToBeVisibleAsync();+ }+}+```+</TabItem>+<TabItem value="xunit-v3">++```csharp title="UnitTest1.cs"+using System.Text.RegularExpressions;+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;++namespace PlaywrightTests;+public class UnitTest1: PageTest{[Fact]@@ -231,7 +266,7 @@ Here is the list of the most popular async assertions. Note that there are [many## Test Isolation-The Playwright NUnit and MSTest test framework base classes will isolate each test from each other by providing a separate `Page` instance. Pages are isolated between tests due to the Browser Context, which is equivalent to a brand new browser profile, where every test gets a fresh environment, even when multiple tests run in a single Browser.+The Playwright NUnit, MSTest, xUnit, and xUnit v3 test framework base classes will isolate each test from each other by providing a separate `Page` instance. Pages are isolated between tests due to the Browser Context, which is equivalent to a brand new browser profile, where every test gets a fresh environment, even when multiple tests run in a single Browser.<TabsgroupId="test-runners"@@ -240,6 +275,7 @@ The Playwright NUnit and MSTest test framework base classes will isolate each te{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -303,6 +339,25 @@ public class UnitTest1: PageTest}```+</TabItem>+<TabItem value="xunit-v3">++```csharp title="UnitTest1.cs"+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;++namespace PlaywrightTests;++public class UnitTest1: PageTest+{+ [Fact]+ public async Task BasicTest()+ {+ await Page.GotoAsync("https://playwright.dev");+ }+}+```+</TabItem></Tabs>@@ -315,6 +370,7 @@ public class UnitTest1: PageTest{label: 'MSTest', value: 'mstest'},{label: 'NUnit', value: 'nunit'},{label: 'xUnit', value: 'xunit'},+ {label: 'xUnit v3', value: 'xunit-v3'},]}><TabItem value="nunit">@@ -388,6 +444,39 @@ using Microsoft.Playwright.Xunit;namespace PlaywrightTests;+public class UnitTest1: PageTest+{+ [Fact]+ public async Task MainNavigation()+ {+ // Assertions use the expect API.+ await Expect(Page).ToHaveURLAsync("https://playwright.dev/");+ }++ override public async Task InitializeAsync()+ {+ await base.InitializeAsync();+ await Page.GotoAsync("https://playwright.dev");+ }++ public override async Task DisposeAsync()+ {+ Console.WriteLine("After each test cleanup");+ await base.DisposeAsync();+ }+}+```+</TabItem>+<TabItem value="xunit-v3">++You can use `InitializeAsync`/`DisposeAsync` to prepare and clean up your test environment:++```csharp title="UnitTest1.cs"+using Microsoft.Playwright;+using Microsoft.Playwright.Xunit.v3;++namespace PlaywrightTests;+public class UnitTest1: PageTest{[Fact]@@ -419,4 +508,4 @@ public class UnitTest1: PageTest- [Generate tests with Codegen](./codegen-intro.md)- [See a trace of your tests](./trace-viewer-intro.md)- [Run tests on CI](./ci-intro.md)-- [Learn more about the MSTest, NUnit, or xUnit base classes](./test-runners.md)+- [Learn more about the MSTest, NUnit, xUnit, or xUnit v3 base classes](./test-runners.md)