Skip to content

Commit

Permalink
feat: add xUnit testing harness (#3044)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Nov 21, 2024
1 parent 876263f commit 8cd88de
Show file tree
Hide file tree
Showing 15 changed files with 1,024 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/Playwright.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@
var page = await browser.NewPageAsync();
await page.GotoAsync("https://playwright.dev/dotnet");
await page.ScreenshotAsync(new PageScreenshotOptions { Path = "screenshot.png" });

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Playwright\Playwright.csproj" />
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" />
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" />
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Playwright.TestingHarnessTest/tests/baseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const test = base.extend<{
const testDir = testInfo.outputPath();
const testClassName = testInfo.titlePath.join(' ').replace(/[^\w]/g, '');
for (const [fileName, fileContent] of Object.entries(files)) {
await fs.promises.writeFile(path.join(testDir, fileName), unintentFile(fileContent).replace('<class-name>', testClassName));
await fs.promises.writeFile(path.join(testDir, fileName), unintentFile(fileContent).replaceAll('<class-name>', testClassName));
}
const trxFile = path.join(testDir, 'result.trx');
command += ` --logger "trx;logfilename=${trxFile}" --logger "console;verbosity=detailed" --filter "${testClassName}" ${path.join('..', '..')}`;
Expand Down
3 changes: 2 additions & 1 deletion src/Playwright.TestingHarnessTest/tests/mstest/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ test('should be able to make the browser headed via the env', async ({ runTest }
expect(result.stdout).not.toContain("Headless")
});

test('should be able to to parse BrowserName and LaunchOptions.Headless from runsettings', async ({ runTest }) => {
test('should be able to parse BrowserName and LaunchOptions.Headless from runsettings', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
using System;
Expand Down Expand Up @@ -445,6 +445,7 @@ test.describe('Expect() timeout', () => {
expect(result.total).toBe(1);
expect(result.rawStdout).toContain("LocatorAssertions.ToHaveTextAsync with timeout 5000ms")
});

test('should be able to override it via each Expect() call', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
Expand Down
3 changes: 2 additions & 1 deletion src/Playwright.TestingHarnessTest/tests/nunit/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ test('should be able to make the browser headed via the env', async ({ runTest }
expect(result.stdout).not.toContain("Headless")
});

test('should be able to to parse BrowserName and LaunchOptions.Headless from runsettings', async ({ runTest }) => {
test('should be able to parse BrowserName and LaunchOptions.Headless from runsettings', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
using System;
Expand Down Expand Up @@ -440,6 +440,7 @@ test.describe('Expect() timeout', () => {
expect(result.total).toBe(1);
expect(result.rawStdout).toContain("LocatorAssertions.ToHaveTextAsync with timeout 5000ms")
});

test('should be able to override it via each Expect() call', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
Expand Down
Loading

0 comments on commit 8cd88de

Please sign in to comment.