Skip to content

Commit

Permalink
Migrate to xunit v3
Browse files Browse the repository at this point in the history
Migrate to xunit v3.
  • Loading branch information
martincostello committed Dec 22, 2024
1 parent d35576e commit 1f659c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions PlaywrightTests/BrowserFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text.Json;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Playwright;
using Xunit.Abstractions;
using Xunit;

namespace PlaywrightTests;

Expand Down Expand Up @@ -161,7 +161,7 @@ private async Task<IBrowser> CreateBrowserAsync(IPlaywright playwright, string t
{
["browser"] = browser,
["browserstack.accessKey"] = Options.BrowserStackCredentials.AccessKey,
["browserstack.username"] = Options.BrowserStackCredentials.UserName,
["browserstack.username"] = Options.BrowserStackCredentials.UserName,
["build"] = Options.Build ?? GetDefaultBuildNumber(),
["client.playwrightVersion"] = playwrightVersion,
["name"] = testName,
Expand Down
3 changes: 2 additions & 1 deletion PlaywrightTests/PlaywrightTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Expand All @@ -12,7 +13,7 @@
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="9.0.0" />
<PackageReference Include="Microsoft.Playwright" Version="1.49.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0" />
<PackageReference Include="xunit.v3" Version="1.0.0" />
</ItemGroup>
</Project>
13 changes: 8 additions & 5 deletions PlaywrightTests/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

using Microsoft.Playwright;
using Xunit;
using Xunit.Abstractions;

namespace PlaywrightTests;

public class SearchTests(ITestOutputHelper outputHelper) : IAsyncLifetime
{
public Task InitializeAsync()
public ValueTask InitializeAsync()
{
int exitCode = Program.Main(["install"]);

Expand All @@ -18,10 +17,14 @@ public Task InitializeAsync()
throw new InvalidOperationException($"Playwright exited with code {exitCode}.");
}

return Task.CompletedTask;
return ValueTask.CompletedTask;
}

public Task DisposeAsync() => Task.CompletedTask;
public ValueTask DisposeAsync()
{
GC.SuppressFinalize(this);
return ValueTask.CompletedTask;
}

[Theory]
[ClassData(typeof(BrowsersTestData))]
Expand Down Expand Up @@ -55,7 +58,7 @@ await browser.WithPageAsync(async (page) =>
{
await element.ClickAsync();
await element.WaitForElementStateAsync(ElementState.Hidden);
await Task.Delay(TimeSpan.FromSeconds(1));
await Task.Delay(TimeSpan.FromSeconds(1), TestContext.Current.CancellationToken);
}

// Search for the desired term
Expand Down

0 comments on commit 1f659c0

Please sign in to comment.