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..08ef669db 100644
--- a/src/bunit.template/template/.template.config/template.json
+++ b/src/bunit.template/template/.template.config/template.json
@@ -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\""
diff --git a/src/bunit.template/template/Company.BlazorTests1.csproj b/src/bunit.template/template/Company.BlazorTests1.csproj
index 35e5fe7d5..724f030a6 100644
--- a/src/bunit.template/template/Company.BlazorTests1.csproj
+++ b/src/bunit.template/template/Company.BlazorTests1.csproj
@@ -32,6 +32,14 @@
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
diff --git a/src/bunit.template/template/CounterCSharpTests.cs b/src/bunit.template/template/CounterCSharpTests.cs
index 020dfabbd..2f9ee25ab 100644
--- a/src/bunit.template/template/CounterCSharpTests.cs
+++ b/src/bunit.template/template/CounterCSharpTests.cs
@@ -4,7 +4,7 @@ namespace Company.BlazorTests1;
/// These tests are written entirely in C#.
/// Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating-basic-tests-in-cs-files
///
-#if (testFramework_xunit)
+#if (testFramework_xunit || testFramework_xunitv3)
public class CounterCSharpTests : TestContext
#elif (testFramework_nunit)
public class CounterCSharpTests : BunitTestContext
@@ -29,7 +29,7 @@ public void CounterStartsAtZero()
cut.Find("p").MarkupMatches("Current count: 0
");
}
-#if (testFramework_xunit)
+#if (testFramework_xunit || testFramework_xunitv3)
[Fact]
#elif (testFramework_nunit)
[Test]
diff --git a/src/bunit.template/template/CounterRazorTests.razor b/src/bunit.template/template/CounterRazorTests.razor
index 7992eda2d..eb870024c 100644
--- a/src/bunit.template/template/CounterRazorTests.razor
+++ b/src/bunit.template/template/CounterRazorTests.razor
@@ -1,4 +1,4 @@
-@*#if (testFramework_xunit)*@
+@*#if (testFramework_xunit || testFramework_xunitv3) *@
@inherits TestContext
@*#elif (testFramework_nunit)*@
@inherits BunitTestContext
@@ -12,7 +12,7 @@ These tests are written entirely in razor and C# syntax.
Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating-basic-tests-in-razor-files
@code {
-@*#if (testFramework_xunit)*@
+@*#if (testFramework_xunit) || testFramework_xunitv3*@
[Fact]
@*#elif (testFramework_nunit)*@
[Test]
@@ -27,7 +27,7 @@ Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating
// Assert that content of the paragraph shows counter at zero
cut.Find("p").MarkupMatches(@Current count: 0
);
}
-@*#if (testFramework_xunit)*@
+@*#if (testFramework_xunit || testFramework_xunitv3)*@
[Fact]
@*#elif (testFramework_nunit)*@
[Test]
diff --git a/src/bunit.template/template/_Imports.razor b/src/bunit.template/template/_Imports.razor
index 054402d02..1f90d2779 100644
--- a/src/bunit.template/template/_Imports.razor
+++ b/src/bunit.template/template/_Imports.razor
@@ -3,7 +3,7 @@
@using Microsoft.Extensions.DependencyInjection
@using Bunit
@using Bunit.TestDoubles
-@*#if (testFramework_xunit)*@
+@*#if (testFramework_xunit || testFramework_xunitv3)*@
@using Xunit
@*#elif (testFramework_nunit)*@
@using NUnit.Framework