Skip to content

Commit

Permalink
Add support for NUnit4 (#2483)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbreuss committed Nov 30, 2023
1 parent d0175f9 commit 2f56211
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 10 deletions.
1 change: 1 addition & 0 deletions Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ void ReportTestOutcome(params string[] globFilters)
Solution.TestFrameworks.MSpec_Specs,
Solution.TestFrameworks.MSTestV2_Specs,
Solution.TestFrameworks.NUnit3_Specs,
Solution.TestFrameworks.NUnit4_Specs,
Solution.TestFrameworks.XUnit2_Specs
};
Expand Down
25 changes: 17 additions & 8 deletions FluentAssertions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions", "Src\Flu
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit3.Specs", "Tests\TestFrameworks\NUnit3.Specs\NUnit3.Specs.csproj", "{C8335EA3-C6CE-47C9-AB4F-CE37157E1EB2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NUnit4.Specs", "Tests\TestFrameworks\NUnit4.Specs\NUnit4.Specs.csproj", "{23891E7D-05CE-4893-AC38-A95CC9D3603E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSpec.Specs", "Tests\TestFrameworks\MSpec.Specs\MSpec.Specs.csproj", "{4F210C41-7E8E-424A-B956-FC1AA47663C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Tests\Benchmarks\Benchmarks.csproj", "{FCAFB0F1-79EA-4D49-813B-188D4BC4BE71}"
Expand All @@ -52,9 +54,9 @@ Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VB.Specs", "Tests\VB.Specs\
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Specs", "Tests\FSharp.Specs\FSharp.Specs.fsproj", "{0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleExtensions", "Tests\ExampleExtensions\ExampleExtensions.csproj", "{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleExtensions", "Tests\ExampleExtensions\ExampleExtensions.csproj", "{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Extensibility.Specs", "Tests\FluentAssertions.Extensibility.Specs\FluentAssertions.Extensibility.Specs.csproj", "{450FC408-A4E2-4483-B064-2007024D6CF1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Extensibility.Specs", "Tests\FluentAssertions.Extensibility.Specs\FluentAssertions.Extensibility.Specs.csproj", "{450FC408-A4E2-4483-B064-2007024D6CF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -102,6 +104,12 @@ Global
{C8335EA3-C6CE-47C9-AB4F-CE37157E1EB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8335EA3-C6CE-47C9-AB4F-CE37157E1EB2}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{C8335EA3-C6CE-47C9-AB4F-CE37157E1EB2}.Release|Any CPU.Build.0 = Debug|Any CPU
{23891E7D-05CE-4893-AC38-A95CC9D3603E}.CI|Any CPU.ActiveCfg = Debug|Any CPU
{23891E7D-05CE-4893-AC38-A95CC9D3603E}.CI|Any CPU.Build.0 = Debug|Any CPU
{23891E7D-05CE-4893-AC38-A95CC9D3603E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23891E7D-05CE-4893-AC38-A95CC9D3603E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23891E7D-05CE-4893-AC38-A95CC9D3603E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23891E7D-05CE-4893-AC38-A95CC9D3603E}.Release|Any CPU.Build.0 = Release|Any CPU
{4F210C41-7E8E-424A-B956-FC1AA47663C9}.CI|Any CPU.ActiveCfg = Debug|Any CPU
{4F210C41-7E8E-424A-B956-FC1AA47663C9}.CI|Any CPU.Build.0 = Debug|Any CPU
{4F210C41-7E8E-424A-B956-FC1AA47663C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -146,18 +154,18 @@ Global
{0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}.Release|Any CPU.Build.0 = Release|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.CI|Any CPU.ActiveCfg = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.CI|Any CPU.Build.0 = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Release|Any CPU.Build.0 = Release|Any CPU
{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}.CI|Any CPU.ActiveCfg = Debug|Any CPU
{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}.CI|Any CPU.Build.0 = Debug|Any CPU
{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DF4A6FE-AAD0-41E5-B2F4-34166D1B139C}.Release|Any CPU.Build.0 = Release|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.CI|Any CPU.ActiveCfg = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.CI|Any CPU.Build.0 = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{450FC408-A4E2-4483-B064-2007024D6CF1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -169,6 +177,7 @@ Global
{A4E37052-5581-4E70-A9C3-FF8364B2F332} = {4D8FA213-8724-4C43-B68A-F018148D238C}
{34E3713D-C02F-4868-BBE7-47DAD2C7F03D} = {31891850-3EDC-480A-9B6C-F60540E9C90F}
{C8335EA3-C6CE-47C9-AB4F-CE37157E1EB2} = {4D8FA213-8724-4C43-B68A-F018148D238C}
{23891E7D-05CE-4893-AC38-A95CC9D3603E} = {4D8FA213-8724-4C43-B68A-F018148D238C}
{4F210C41-7E8E-424A-B956-FC1AA47663C9} = {4D8FA213-8724-4C43-B68A-F018148D238C}
{FCAFB0F1-79EA-4D49-813B-188D4BC4BE71} = {963262D0-9FD5-4741-8C0E-E2F34F110EF3}
{F5115158-A038-4D14-A04E-46E7863E40B9} = {963262D0-9FD5-4741-8C0E-E2F34F110EF3}
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/FluentAssertions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageDescription>
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or
BDD-style unit tests. Works with .NET Standard 2.0 and higher, .NET Framework 4.7 and higher and .NET 6 and higher.
Supports the unit test frameworks MSTest2, NUnit3, XUnit2 and MSpec.
Supports the unit test frameworks MSTest2, NUnit3, NUnit4, XUnit2 and MSpec.

Supported by InfoSupport B.V.
</PackageDescription>
Expand Down
19 changes: 19 additions & 0 deletions Tests/TestFrameworks/NUnit4.Specs/FrameworkSpecs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using FluentAssertions;
using NUnit.Framework;

namespace NUnit4.Specs;

[TestFixture]
public class FrameworkSpecs
{
[Test]
public void Throw_nunit_framework_exception_for_nunit4_tests()
{
// Act
Action act = () => 0.Should().Be(1);

// Assert
act.Should().Throw<AssertionException>();
}
}
21 changes: 21 additions & 0 deletions Tests/TestFrameworks/NUnit4.Specs/NUnit4.Specs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>NUnit4.Specs</RootNamespace>
<AssemblyName>NUnit4.Specs</AssemblyName>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Src\FluentAssertions\FluentAssertions.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions docs/_pages/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sidebar:

* Introduced a new assembly-level attribute that you can use to initialize Fluent Assertions before the first assertion - [#2292](https://github.com/fluentassertions/fluentassertions/pull/2292)
* Ensure compatibility with .NET 8 - [#2466](https://github.com/fluentassertions/fluentassertions/pull/2466)
* Add support for NUnit 4 - [#2483](https://github.com/fluentassertions/fluentassertions/pull/2483)

### Improvements
* Improve failure message for string assertions when checking for equality - [#2307](https://github.com/fluentassertions/fluentassertions/pull/2307)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
image_path: /assets/images/checklist.svg
excerpt: '
Works with .NET Standard 2.0 and higher, .NET Framework 4.7 and higher and .NET 6 and higher.
Supports MSTest2, xUnit2, NUnit3 and MSpec.
Supports MSTest2, xUnit2, NUnit3, NUnit4 and MSpec.
'
- title: "Great Support"
image_path: /assets/images/customer-service.svg
Expand Down

0 comments on commit 2f56211

Please sign in to comment.