Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<?xml version="1.0" encoding="utf-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></Project>' >> ${{ github.workspace }}/TemplateTestXunitv3/Directory.Build.props
echo '<Project><PropertyGroup><ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally></PropertyGroup></Project>' >> ${{ 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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<PackageVersion Include="Autofac" Version="8.1.0" />
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />

<PackageVersion Include="Serilog" Version="4.1.0"/>
<PackageVersion Include="Serilog" Version="4.2.0"/>
<PackageVersion Include="Serilog.Expressions" Version="5.0.0"/>
<PackageVersion Include="AngleSharp.Diffing" Version="1.0.0"/>
<PackageVersion Include="AngleSharp" Version="1.1.2"/>
<PackageVersion Include="AngleSharp" Version="1.2.0"/>
<PackageVersion Include="AngleSharp.Css" Version="1.0.0-beta.144"/>
</ItemGroup>

<ItemGroup Label="Package Versioning">
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.146" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
</ItemGroup>

<ItemGroup Label="System.Text.Json Vulnerability">
Expand Down Expand Up @@ -114,24 +114,24 @@
<PackageVersion Include="AutoFixture.Xunit2" Version="4.18.1"/>
<PackageVersion Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageVersion Include="MSTest.TestFramework" Version="3.6.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="RichardSzalay.MockHttp" Version="7.0.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.0" />
<PackageVersion Include="Shouldly" Version="4.2.1"/>
<PackageVersion Include="Verify.SourceGenerators" Version="2.5.0"/>
<PackageVersion Include="Verify.Xunit" Version="28.4.0"/>
<PackageVersion Include="Verify.Xunit" Version="28.8.1"/>
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24"/>
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.3" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.3" />
<PackageVersion Include="nunit" Version="4.2.2" />
<PackageVersion Include="xunit" Version="2.9.2"/>
<PackageVersion Include="xunit" Version="2.9.3"/>
<PackageVersion Include="xunit.abstractions" Version="2.0.3"/>
<PackageVersion Include="xunit.assert" Version="2.9.2"/>
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.2"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2"/>
<PackageVersion Include="xunit.assert" Version="2.9.3"/>
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.3"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1"/>
</ItemGroup>

<ItemGroup Label="Test Dependencies - Legacy" Condition="'$(TargetFramework)' == 'netcoreapp3.1' Or '$(TargetFramework)' == 'net5.0'">
Expand Down
4 changes: 3 additions & 1 deletion src/bunit.core/Asserting/ActualExpectedAssertException.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Bunit.Internal.XUnitExceptions;

namespace Bunit.Asserting;

/// <summary>
/// Represents a generic assert exception used when an actual result does not match an expected result.
/// </summary>
[Serializable]
public class ActualExpectedAssertException : Exception
public class ActualExpectedAssertException : Exception, IAssertionException
{
/// <summary>
/// Initializes a new instance of the <see cref="ActualExpectedAssertException"/> class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Bunit.Internal.XUnitExceptions;

namespace Bunit.Extensions.WaitForHelpers;

/// <summary>
/// Represents an exception thrown when the <see cref="WaitForHelper{T}"/> does not complete successfully.
/// </summary>
[Serializable]
public sealed class WaitForFailedException : Exception
public sealed class WaitForFailedException : Exception, ITestTimeoutException
{
/// <summary>
/// Initializes a new instance of the <see cref="WaitForFailedException"/> class.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Bunit.Internal.XUnitExceptions;

/// <summary>
/// This is a marker interface for xUnit.v3 that will cause xUnit to consider the failure cause to be an assertion failure.
/// </summary>
internal interface IAssertionException;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Bunit.Internal.XUnitExceptions;

/// <summary>
/// This is a marker interface for xUnit.v3 that will cause xUnit to consider the failure cause to be a timeout.
/// </summary>
internal interface ITestTimeoutException;
2 changes: 1 addition & 1 deletion src/bunit.core/ParameterException.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Bunit.RazorTesting;

/// <summary>
/// Represents an missing or invalid Blazor parameter on a Blazor component.
/// Represents a missing or invalid Blazor parameter on a Blazor component.
/// </summary>
[Serializable]
public sealed class ParameterException : ArgumentException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
21 changes: 10 additions & 11 deletions src/bunit.template/template/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"modifiers": [
{
"exclude": [ "BunitTestContext.cs" ],
"condition": "(testFramework_xunit)"
"condition": "(testFramework_xunit || testFramework_xunitv3)"
}
]
}
Expand Down Expand Up @@ -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",
Expand All @@ -73,6 +78,10 @@
"type": "computed",
"value": "UnitTestFramework == \"xunit\""
},
"testFramework_xunitv3": {
"type": "computed",
"value": "UnitTestFramework == \"xunitv3\""
},
"testFramework_mstest": {
"type": "computed",
"value": "UnitTestFramework == \"mstest\""
Expand All @@ -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",
Expand Down
23 changes: 16 additions & 7 deletions src/bunit.template/template/Company.BlazorTests1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,44 @@
<Using Include="Bunit.TestDoubles" />
<Using Include="Microsoft.Extensions.DependencyInjection" />
<Using Include="Xunit" Condition="'$(testFramework_xunit)' == 'true'"/>
<Using Include="Xunit" Condition="'$(testFramework_xunitv3)' == 'true'"/>
<Using Include="NUnit.Framework" Condition="'$(testFramework_nunit)' == 'true'"/>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" Condition="'$(testFramework_mstest)' == 'true'"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="coverlet.collector" Version="6.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(testFramework_xunit)' == 'true'">
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(testFramework_xunitv3)' == 'true'">
<PackageReference Include="xunit.v3" Version="1.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(testFramework_nunit)' == 'true'">
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(testFramework_mstest)' == 'true'">
<PackageReference Include="MSTest.TestAdapter" Version="3.6.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions src/bunit.template/template/CounterCSharpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace Company.BlazorTests1;
/// </summary>
#if (testFramework_xunit)
public class CounterCSharpTests : TestContext
#elif (testFramework_xunitv3)
// The full qualified namespace for bUnit TestContext is used here as xunit v3 also offers a TestContext class
public class CounterCSharpTests : Bunit.TestContext
#elif (testFramework_nunit)
public class CounterCSharpTests : BunitTestContext
#elif (testFramework_mstest)
Expand All @@ -15,6 +18,8 @@ public class CounterCSharpTests : BunitTestContext
{
#if (testFramework_xunit)
[Fact]
#elif (testFramework_xunitv3)
[Fact]
#elif (testFramework_nunit)
[Test]
#elif (testFramework_mstest)
Expand All @@ -31,6 +36,8 @@ public void CounterStartsAtZero()

#if (testFramework_xunit)
[Fact]
#elif (testFramework_xunitv3)
[Fact]
#elif (testFramework_nunit)
[Test]
#elif (testFramework_mstest)
Expand Down
9 changes: 8 additions & 1 deletion src/bunit.template/template/CounterRazorTests.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@*#if (testFramework_xunit)*@
@*#if (testFramework_xunit) *@
@inherits TestContext
@*#elif (testFramework_xunitv3)*@
@* The full qualified namespace for bUnit TestContext is used here as xunit v3 also offers a TestContext class *@
@inherits Bunit.TestContext
@*#elif (testFramework_nunit)*@
@inherits BunitTestContext
@*#elif (testFramework_mstest)*@
Expand All @@ -14,6 +17,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)*@
Expand All @@ -29,6 +34,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)*@
Expand Down
2 changes: 2 additions & 0 deletions src/bunit.template/template/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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)*@
Expand Down
2 changes: 1 addition & 1 deletion src/bunit.web/Extensions/ElementRemovedFromDomException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Bunit;

/// <summary>
/// Represents an exception that is thrown when trying to access an element
/// that was previous found in the DOM.
/// that was previously found in the DOM.
/// </summary>
[Serializable]
public sealed class ElementRemovedFromDomException : ElementNotFoundException
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.37",
"version": "1.38",
"assemblyVersion": {
"precision": "revision"
},
Expand Down
Loading