diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6e106dd43..b103dc6aa 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -191,6 +191,14 @@ jobs:
dotnet restore ${{ github.workspace }}/TemplateTestXunit --source https://api.nuget.org/v3/index.json --source ${{ env.NUGET_DIRECTORY }}
dotnet test ${{ github.workspace }}/TemplateTestXunit
+ - name: ✔ Verify xUnit.v3 template
+ run: |
+ dotnet new bunit --framework xunitv3 --no-restore -o ${{ github.workspace }}/TemplateTestXunitv3
+ echo '' >> ${{ github.workspace }}/TemplateTestXunitv3/Directory.Build.props
+ echo 'false' >> ${{ github.workspace }}/TemplateTestXunitv3/Directory.Packages.props
+ dotnet restore ${{ github.workspace }}/TemplateTestXunitv3 --source https://api.nuget.org/v3/index.json --source ${{ env.NUGET_DIRECTORY }}
+ dotnet test ${{ github.workspace }}/TemplateTestXunitv3
+
- name: ✔ Verify NUnit template
run: |
dotnet new bunit --framework nunit --no-restore -o ${{ github.workspace }}/TemplateTestNunit
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 54d178487..e667047d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad
## [Unreleased]
+### Added
+
+- Added support for xunit v3 in the bunit.template. By [@linkdotnet](https://github.com/linkdotnet).
+
## [1.37.7] - 2024-12-13
### Added
diff --git a/src/bunit.template/template/.template.config/dotnetcli.host.json b/src/bunit.template/template/.template.config/dotnetcli.host.json
index c8adcf8a7..ced81d900 100644
--- a/src/bunit.template/template/.template.config/dotnetcli.host.json
+++ b/src/bunit.template/template/.template.config/dotnetcli.host.json
@@ -15,6 +15,7 @@
},
"usageExamples": [
"--framework xunit --sdk net8.0",
+ "--framework xunitv3 --sdk net8.0",
"--framework nunit --sdk net8.0",
"--framework mstest --sdk net8.0"
]
diff --git a/src/bunit.template/template/.template.config/template.json b/src/bunit.template/template/.template.config/template.json
index 646e9a8ef..81e3820c6 100644
--- a/src/bunit.template/template/.template.config/template.json
+++ b/src/bunit.template/template/.template.config/template.json
@@ -24,7 +24,7 @@
"modifiers": [
{
"exclude": [ "BunitTestContext.cs" ],
- "condition": "(testFramework_xunit)"
+ "condition": "(testFramework_xunit || testFramework_xunitv3)"
}
]
}
@@ -58,6 +58,11 @@
"description": "xUnit unit testing framework",
"displayName": "xUnit"
},
+ {
+ "choice": "xunitv3",
+ "description": "xUnit v3 unit testing framework",
+ "displayName": "xUnit v3"
+ },
{
"choice": "mstest",
"description": "MSTest unit testing framework",
@@ -73,6 +78,10 @@
"type": "computed",
"value": "UnitTestFramework == \"xunit\""
},
+ "testFramework_xunitv3": {
+ "type": "computed",
+ "value": "UnitTestFramework == \"xunitv3\""
+ },
"testFramework_mstest": {
"type": "computed",
"value": "UnitTestFramework == \"mstest\""
@@ -85,16 +94,6 @@
"defaultValue": "net9.0",
"replaces": "targetSdk",
"choices": [
- {
- "choice": "net6.0",
- "description": ".net 6.0",
- "displayName": ".net 6.0"
- },
- {
- "choice": "net7.0",
- "description": ".net 7.0",
- "displayName": ".net 7.0"
- },
{
"choice": "net8.0",
"description": ".net 8.0",
diff --git a/src/bunit.template/template/Company.BlazorTests1.csproj b/src/bunit.template/template/Company.BlazorTests1.csproj
index 35e5fe7d5..5cf40a48c 100644
--- a/src/bunit.template/template/Company.BlazorTests1.csproj
+++ b/src/bunit.template/template/Company.BlazorTests1.csproj
@@ -11,14 +11,15 @@
+
-
-
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -32,14 +33,22 @@
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
-
+
-
-
+
+
diff --git a/src/bunit.template/template/CounterCSharpTests.cs b/src/bunit.template/template/CounterCSharpTests.cs
index 020dfabbd..254157b13 100644
--- a/src/bunit.template/template/CounterCSharpTests.cs
+++ b/src/bunit.template/template/CounterCSharpTests.cs
@@ -6,6 +6,8 @@ namespace Company.BlazorTests1;
///
#if (testFramework_xunit)
public class CounterCSharpTests : TestContext
+#elif (testFramework_xunitv3)
+public class CounterCSharpTests : Bunit.TestContext
#elif (testFramework_nunit)
public class CounterCSharpTests : BunitTestContext
#elif (testFramework_mstest)
@@ -15,6 +17,8 @@ public class CounterCSharpTests : BunitTestContext
{
#if (testFramework_xunit)
[Fact]
+#elif (testFramework_xunitv3)
+ [Fact]
#elif (testFramework_nunit)
[Test]
#elif (testFramework_mstest)
@@ -31,6 +35,8 @@ public void CounterStartsAtZero()
#if (testFramework_xunit)
[Fact]
+#elif (testFramework_xunitv3)
+ [Fact]
#elif (testFramework_nunit)
[Test]
#elif (testFramework_mstest)
diff --git a/src/bunit.template/template/CounterRazorTests.razor b/src/bunit.template/template/CounterRazorTests.razor
index 7992eda2d..f74a8a4a1 100644
--- a/src/bunit.template/template/CounterRazorTests.razor
+++ b/src/bunit.template/template/CounterRazorTests.razor
@@ -1,5 +1,7 @@
-@*#if (testFramework_xunit)*@
+@*#if (testFramework_xunit) *@
@inherits TestContext
+@*#elif (testFramework_xunitv3)*@
+@inherits Bunit.TestContext
@*#elif (testFramework_nunit)*@
@inherits BunitTestContext
@*#elif (testFramework_mstest)*@
@@ -14,6 +16,8 @@ Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating
@code {
@*#if (testFramework_xunit)*@
[Fact]
+@*#elif (testFramework_xunitv3)*@
+ [Fact]
@*#elif (testFramework_nunit)*@
[Test]
@*#elif (testFramework_mstest)*@
@@ -29,6 +33,8 @@ Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating
}
@*#if (testFramework_xunit)*@
[Fact]
+@*#elif (testFramework_xunitv3)*@
+ [Fact]
@*#elif (testFramework_nunit)*@
[Test]
@*#elif (testFramework_mstest)*@
diff --git a/src/bunit.template/template/_Imports.razor b/src/bunit.template/template/_Imports.razor
index 054402d02..e49ef971e 100644
--- a/src/bunit.template/template/_Imports.razor
+++ b/src/bunit.template/template/_Imports.razor
@@ -5,6 +5,8 @@
@using Bunit.TestDoubles
@*#if (testFramework_xunit)*@
@using Xunit
+@*#elif (testFramework_xunitv3)*@
+@using Xunit
@*#elif (testFramework_nunit)*@
@using NUnit.Framework
@*#elif (testFramework_mstest)*@