Skip to content

Commit 085215a

Browse files
committed
feat: add support for xUnit.v3
1 parent 0586b06 commit 085215a

15 files changed

+1035
-10
lines changed

src/Playwright.TestingHarnessTest/Playwright.TestingHarnessTest.csproj

+20-8
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,33 @@
66
<ReleaseVersion>0.0.0</ReleaseVersion>
77
<LangVersion>12</LangVersion>
88
</PropertyGroup>
9+
910
<Import Project="../Common/SignAssembly.props" />
1011

1112
<ItemGroup>
1213
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
13-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
14-
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
15-
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
16-
<PackageReference Include="xunit" Version="2.9.2" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
14+
15+
<!-- MSTest -->
16+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />
17+
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />
18+
19+
<!-- NUnit -->
20+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" Condition="'$(TEST_MODE)' == 'nunit'" />
21+
22+
<!-- xUnit -->
23+
<PackageReference Include="xunit" Version="2.9.2" Condition="'$(TEST_MODE)' == 'xunit'" />
24+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" Condition="'$(TEST_MODE)' == 'xunit'" />
25+
26+
<!-- xUnit.v3 -->
27+
<PackageReference Include="xunit.v3" Version="1.0.1" Condition="'$(TEST_MODE)' == 'xunit.v3'" />
28+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" Condition="'$(TEST_MODE)' == 'xunit.v3'" />
1829
</ItemGroup>
1930

2031
<ItemGroup>
2132
<ProjectReference Include="..\Playwright\Playwright.csproj" />
22-
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" />
23-
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" />
24-
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" />
33+
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" Condition="'$(TEST_MODE)' == 'mstest'" />
34+
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" Condition="'$(TEST_MODE)' == 'nunit'" />
35+
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" Condition="'$(TEST_MODE)' == 'xunit'" />
36+
<ProjectReference Include="..\Playwright.Xunit.v3\Playwright.Xunit.v3.csproj" Condition="'$(TEST_MODE)' == 'xunit.v3'" />
2537
</ItemGroup>
2638
</Project>

src/Playwright.TestingHarnessTest/tests/baseTest.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ type RunResult = {
1616
}
1717

1818
export const test = base.extend<{
19+
testMode: 'nunit' | 'mstest' | 'xunit' | 'xunit.v3';
1920
runTest: (files: Record<string, string>, command: string, env?: NodeJS.ProcessEnv) => Promise<RunResult>;
2021
}>({
21-
runTest: async ({ }, use, testInfo) => {
22+
testMode: null,
23+
runTest: async ({ testMode }, use, testInfo) => {
2224
const testResults: RunResult[] = [];
2325
await use(async (files, command, env) => {
2426
const testDir = testInfo.outputPath();
@@ -34,7 +36,8 @@ export const test = base.extend<{
3436
env: {
3537
...process.env,
3638
...env,
37-
NODE_OPTIONS: undefined
39+
NODE_OPTIONS: undefined,
40+
TEST_MODE: testMode,
3841
},
3942
stdio: 'pipe',
4043
});

src/Playwright.TestingHarnessTest/tests/mstest/basic.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import http from 'http';
2626
import { test, expect } from '../baseTest';
2727
import httpProxy from 'http-proxy';
2828

29+
test.use({testMode: 'mstest'});
30+
2931
test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
3032
const result = await runTest({
3133
'ExampleTests.cs': `

src/Playwright.TestingHarnessTest/tests/nunit/basic.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import http from 'http';
2626
import { test, expect } from '../baseTest';
2727
import httpProxy from 'http-proxy';
2828

29+
test.use({testMode: 'nunit'});
30+
2931
test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
3032
const result = await runTest({
3133
'ExampleTests.cs': `

0 commit comments

Comments
 (0)