Skip to content

Commit

Permalink
feat: add support for xUnit.v3
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Jan 23, 2025
1 parent 0586b06 commit 085215a
Show file tree
Hide file tree
Showing 15 changed files with 1,035 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,33 @@
<ReleaseVersion>0.0.0</ReleaseVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>

<Import Project="../Common/SignAssembly.props" />

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<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" />

<!-- MSTest -->
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />

<!-- NUnit -->
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" Condition="'$(TEST_MODE)' == 'nunit'" />

<!-- xUnit -->
<PackageReference Include="xunit" Version="2.9.2" Condition="'$(TEST_MODE)' == 'xunit'" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" Condition="'$(TEST_MODE)' == 'xunit'" />

<!-- xUnit.v3 -->
<PackageReference Include="xunit.v3" Version="1.0.1" Condition="'$(TEST_MODE)' == 'xunit.v3'" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" Condition="'$(TEST_MODE)' == 'xunit.v3'" />
</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" />
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" Condition="'$(TEST_MODE)' == 'mstest'" />
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" Condition="'$(TEST_MODE)' == 'nunit'" />
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" Condition="'$(TEST_MODE)' == 'xunit'" />
<ProjectReference Include="..\Playwright.Xunit.v3\Playwright.Xunit.v3.csproj" Condition="'$(TEST_MODE)' == 'xunit.v3'" />
</ItemGroup>
</Project>
7 changes: 5 additions & 2 deletions src/Playwright.TestingHarnessTest/tests/baseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ type RunResult = {
}

export const test = base.extend<{
testMode: 'nunit' | 'mstest' | 'xunit' | 'xunit.v3';
runTest: (files: Record<string, string>, command: string, env?: NodeJS.ProcessEnv) => Promise<RunResult>;
}>({
runTest: async ({ }, use, testInfo) => {
testMode: null,
runTest: async ({ testMode }, use, testInfo) => {
const testResults: RunResult[] = [];
await use(async (files, command, env) => {
const testDir = testInfo.outputPath();
Expand All @@ -34,7 +36,8 @@ export const test = base.extend<{
env: {
...process.env,
...env,
NODE_OPTIONS: undefined
NODE_OPTIONS: undefined,
TEST_MODE: testMode,
},
stdio: 'pipe',
});
Expand Down
2 changes: 2 additions & 0 deletions src/Playwright.TestingHarnessTest/tests/mstest/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import http from 'http';
import { test, expect } from '../baseTest';
import httpProxy from 'http-proxy';

test.use({testMode: 'mstest'});

test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
Expand Down
2 changes: 2 additions & 0 deletions src/Playwright.TestingHarnessTest/tests/nunit/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import http from 'http';
import { test, expect } from '../baseTest';
import httpProxy from 'http-proxy';

test.use({testMode: 'nunit'});

test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
Expand Down
Loading

0 comments on commit 085215a

Please sign in to comment.