Skip to content

Commit b35b84c

Browse files
committed
feat: Add templates for xunit.v3
1 parent 4cc05b4 commit b35b84c

File tree

8 files changed

+52
-17
lines changed

8 files changed

+52
-17
lines changed

Diff for: .github/workflows/ci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ jobs:
191191
dotnet restore ${{ github.workspace }}/TemplateTestXunit --source https://api.nuget.org/v3/index.json --source ${{ env.NUGET_DIRECTORY }}
192192
dotnet test ${{ github.workspace }}/TemplateTestXunit
193193
194+
- name: ✔ Verify xUnit.v3 template
195+
run: |
196+
dotnet new bunit --framework xunitv3 --no-restore -o ${{ github.workspace }}/TemplateTestXunitv3
197+
echo '<?xml version="1.0" encoding="utf-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></Project>' >> ${{ github.workspace }}/TemplateTestXunitv3/Directory.Build.props
198+
echo '<Project><PropertyGroup><ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally></PropertyGroup></Project>' >> ${{ github.workspace }}/TemplateTestXunitv3/Directory.Packages.props
199+
dotnet restore ${{ github.workspace }}/TemplateTestXunitv3 --source https://api.nuget.org/v3/index.json --source ${{ env.NUGET_DIRECTORY }}
200+
dotnet test ${{ github.workspace }}/TemplateTestXunitv3
201+
194202
- name: ✔ Verify NUnit template
195203
run: |
196204
dotnet new bunit --framework nunit --no-restore -o ${{ github.workspace }}/TemplateTestNunit

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Added support for xunit v3 in the bunit.template. By [@linkdotnet](https://github.com/linkdotnet).
12+
913
## [1.37.7] - 2024-12-13
1014

1115
### Added

Diff for: src/bunit.template/template/.template.config/dotnetcli.host.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"usageExamples": [
1717
"--framework xunit --sdk net8.0",
18+
"--framework xunitv3 --sdk net8.0",
1819
"--framework nunit --sdk net8.0",
1920
"--framework mstest --sdk net8.0"
2021
]

Diff for: src/bunit.template/template/.template.config/template.json

+10-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"modifiers": [
2525
{
2626
"exclude": [ "BunitTestContext.cs" ],
27-
"condition": "(testFramework_xunit)"
27+
"condition": "(testFramework_xunit || testFramework_xunitv3)"
2828
}
2929
]
3030
}
@@ -58,6 +58,11 @@
5858
"description": "xUnit unit testing framework",
5959
"displayName": "xUnit"
6060
},
61+
{
62+
"choice": "xunitv3",
63+
"description": "xUnit v3 unit testing framework",
64+
"displayName": "xUnit v3"
65+
},
6166
{
6267
"choice": "mstest",
6368
"description": "MSTest unit testing framework",
@@ -73,6 +78,10 @@
7378
"type": "computed",
7479
"value": "UnitTestFramework == \"xunit\""
7580
},
81+
"testFramework_xunitv3": {
82+
"type": "computed",
83+
"value": "UnitTestFramework == \"xunitv3\""
84+
},
7685
"testFramework_mstest": {
7786
"type": "computed",
7887
"value": "UnitTestFramework == \"mstest\""
@@ -85,16 +94,6 @@
8594
"defaultValue": "net9.0",
8695
"replaces": "targetSdk",
8796
"choices": [
88-
{
89-
"choice": "net6.0",
90-
"description": ".net 6.0",
91-
"displayName": ".net 6.0"
92-
},
93-
{
94-
"choice": "net7.0",
95-
"description": ".net 7.0",
96-
"displayName": ".net 7.0"
97-
},
9897
{
9998
"choice": "net8.0",
10099
"description": ".net 8.0",

Diff for: src/bunit.template/template/Company.BlazorTests1.csproj

+14-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
<Using Include="Bunit.TestDoubles" />
1212
<Using Include="Microsoft.Extensions.DependencyInjection" />
1313
<Using Include="Xunit" Condition="'$(testFramework_xunit)' == 'true'"/>
14+
<Using Include="Xunit" Condition="'$(testFramework_xunitv3)' == 'true'"/>
1415
<Using Include="NUnit.Framework" Condition="'$(testFramework_nunit)' == 'true'"/>
1516
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" Condition="'$(testFramework_mstest)' == 'true'"/>
1617
</ItemGroup>
1718

1819
<ItemGroup>
1920
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
21-
<PackageReference Include="coverlet.collector" Version="6.0.0">
21+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
22+
<PackageReference Include="coverlet.collector" Version="6.0.2">
2223
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2324
<PrivateAssets>all</PrivateAssets>
2425
</PackageReference>
@@ -32,14 +33,22 @@
3233
</PackageReference>
3334
</ItemGroup>
3435

36+
<ItemGroup Condition="'$(testFramework_xunitv3)' == 'true'">
37+
<PackageReference Include="xunit.v3" Version="1.0.0" />
38+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
39+
<PrivateAssets>all</PrivateAssets>
40+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
41+
</PackageReference>
42+
</ItemGroup>
43+
3544
<ItemGroup Condition="'$(testFramework_nunit)' == 'true'">
36-
<PackageReference Include="NUnit" Version="4.2.2" />
45+
<PackageReference Include="NUnit" Version="4.3.0" />
3746
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
3847
</ItemGroup>
3948

4049
<ItemGroup Condition="'$(testFramework_mstest)' == 'true'">
41-
<PackageReference Include="MSTest.TestAdapter" Version="3.6.2" />
42-
<PackageReference Include="MSTest.TestFramework" Version="3.6.2" />
50+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
51+
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
4352
</ItemGroup>
4453

4554
</Project>

Diff for: src/bunit.template/template/CounterCSharpTests.cs

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace Company.BlazorTests1;
66
/// </summary>
77
#if (testFramework_xunit)
88
public class CounterCSharpTests : TestContext
9+
#elif (testFramework_xunitv3)
10+
public class CounterCSharpTests : Bunit.TestContext
911
#elif (testFramework_nunit)
1012
public class CounterCSharpTests : BunitTestContext
1113
#elif (testFramework_mstest)
@@ -15,6 +17,8 @@ public class CounterCSharpTests : BunitTestContext
1517
{
1618
#if (testFramework_xunit)
1719
[Fact]
20+
#elif (testFramework_xunitv3)
21+
[Fact]
1822
#elif (testFramework_nunit)
1923
[Test]
2024
#elif (testFramework_mstest)
@@ -31,6 +35,8 @@ public void CounterStartsAtZero()
3135

3236
#if (testFramework_xunit)
3337
[Fact]
38+
#elif (testFramework_xunitv3)
39+
[Fact]
3440
#elif (testFramework_nunit)
3541
[Test]
3642
#elif (testFramework_mstest)

Diff for: src/bunit.template/template/CounterRazorTests.razor

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
@*#if (testFramework_xunit)*@
1+
@*#if (testFramework_xunit) *@
22
@inherits TestContext
3+
@*#elif (testFramework_xunitv3)*@
4+
@inherits Bunit.TestContext
35
@*#elif (testFramework_nunit)*@
46
@inherits BunitTestContext
57
@*#elif (testFramework_mstest)*@
@@ -14,6 +16,8 @@ Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating
1416
@code {
1517
@*#if (testFramework_xunit)*@
1618
[Fact]
19+
@*#elif (testFramework_xunitv3)*@
20+
[Fact]
1721
@*#elif (testFramework_nunit)*@
1822
[Test]
1923
@*#elif (testFramework_mstest)*@
@@ -29,6 +33,8 @@ Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating
2933
}
3034
@*#if (testFramework_xunit)*@
3135
[Fact]
36+
@*#elif (testFramework_xunitv3)*@
37+
[Fact]
3238
@*#elif (testFramework_nunit)*@
3339
[Test]
3440
@*#elif (testFramework_mstest)*@

Diff for: src/bunit.template/template/_Imports.razor

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
@using Bunit.TestDoubles
66
@*#if (testFramework_xunit)*@
77
@using Xunit
8+
@*#elif (testFramework_xunitv3)*@
9+
@using Xunit
810
@*#elif (testFramework_nunit)*@
911
@using NUnit.Framework
1012
@*#elif (testFramework_mstest)*@

0 commit comments

Comments
 (0)