From 42348b12afa4dfa14e312bb16a451331b4a9707e Mon Sep 17 00:00:00 2001 From: Milan Gardian Date: Fri, 6 Sep 2024 14:30:41 -0600 Subject: [PATCH] Update Akka.TestKit.NUnit to NUnit v4 (3rd attempt) (#136) * Update to NUnit 4 This commit is based on the work of Sean Killeen in PR #112. Additional changes: * add net462 as target framework * set C# version in test projects to C# 10 so that file scoped namespaces work * Use constraint assertion model even in NUnit 3 adapter - This improves consistency between NUnit 3 and 4 adapters * Convert "AssertEqual-with-comparer" to NUnit constraint model Our adapters are no longer using custom assertions. This will result in failure reports that are consistent with other NUnit reports, especially when the report output changes (like it did between NUnit 3 and 4). * Apply ".editorconfig" configuration to "Directory.Build.props" This commit only changes indentation whitespace, making this MSBuild file consistent with other MSBuild files in the repository (.csproj). * Add missing/recommended NuGet package properties * Replace obsolete "PackageIconUrl" with "PackageIcon" Fixes warning NU5048 during "dotnet pack". https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5048 * Replace obsolete "PackageLicenseUrl" with "PackageLicenseExpression" * Simplify ".csproj" files + move common references to "Directory.Build.props" * Dynamically fill in current copyright year * Consolidate release notes + bump version to 1.6.0-preview.1 * Move "PackageReference" back to ".csproj" files * Fix NuGet package name in "RELEASE_NOTES.md" - Thanks FarrisPandell * NuGet update 2024-09-06 Akka.TestKit 1.5.28, Microsoft.NET.Test.Sdk 17.11.1 * Delete empty lines after version headers in "RELEASE_NOTES.md" - Empty lines are confusing Nuke build --------- Co-authored-by: Urs Metz --- .gitattributes | 4 +- RELEASE_NOTES.md | 21 ++++-- .../Akka.TestKit.NUnit.Tests.csproj | 21 ++---- .../Akka.TestKit.NUnit.csproj | 13 ++-- src/Akka.TestKit.NUnit/NUnitAssertions.cs | 18 ++--- .../Akka.TestKit.NUnit3.Tests.csproj | 21 ++---- .../Akka.TestKit.NUnit3.csproj | 14 ++-- src/Akka.TestKit.NUnit3/NUnitAssertions.cs | 18 ++--- src/Directory.Build.props | 64 ++++++++++++------ src/akka.png | Bin 0 -> 2338 bytes 10 files changed, 95 insertions(+), 99 deletions(-) create mode 100644 src/akka.png diff --git a/.gitattributes b/.gitattributes index 81956b1..c38b4b4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,6 @@ # Auto detect text files and perform LF normalization * text=auto - # Custom for Visual Studio *.cs diff=csharp *.sln merge=union @@ -29,3 +28,6 @@ *.txt text eol=crlf build.sh eol=lf + +# Binary files (no newline adjustment) +*.png binary diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9f7ec39..8465f54 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,10 +1,17 @@ +## [1.6.0] / September 2024 +- Bump `Akka.TestKit` to [1.5.28](https://github.com/akkadotnet/akka.net/releases/tag/1.5.28) +- Bump `NUnit3TestAdapter` to [4.6.0](https://github.com/nunit/nunit3-vs-adapter/releases/tag/V4.6.0) +- Add `NUnit.Analyzers` version [4.3.0](https://github.com/nunit/nunit.analyzers/releases/tag/4.3.0) to ensure we follow NUnit best practices. +- Add support for [NUnit 4.2.2](https://github.com/nunit/nunit/releases/tag/4.2.2) in addition to NUnit 3. + `Akka.TestKit.NUnit` targets NUnit 4, while `Akka.TestKit.NUnit3` targets NUnit 3. + ## [1.5.24] / June 11 2024 - - [Bump Akka.TestKit to 1.5.24](https://github.com/akkadotnet/akka.net/releases/tag/1.5.24) - - [Bump NUnit3TestAdapter to 4.5.0](https://github.com/akkadotnet/Akka.TestKit.NUnit/pull/97) - - [Bump NUnit to 3.14.0](https://github.com/akkadotnet/Akka.TestKit.NUnit/pull/116) +- Bump Akka.TestKit to [1.5.24](https://github.com/akkadotnet/akka.net/releases/tag/1.5.24) ([#124](https://github.com/akkadotnet/Akka.TestKit.NUnit/pull/124)) +- Bump NUnit3TestAdapter to [4.5.0](https://github.com/nunit/nunit3-vs-adapter/releases/tag/V4.5.0) ([#97](https://github.com/akkadotnet/Akka.TestKit.NUnit/pull/97)) +- Bump NUnit to [3.14.0](https://github.com/nunit/nunit/releases/tag/v3.14.0) ([#116](https://github.com/akkadotnet/Akka.TestKit.NUnit/pull/116)) ## [1.4.39] / July 22 2022 - - Support for Akka 1.4.39 - - Support for NUnit 3.13.3 - - Now targets `netstandard2.0` - - All `TestKit` classes now implement `[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]` which guarantees a unique `ActorSystem` instance per-run. All previous TestKit hacks needed to support this are now removed. See https://github.com/akkadotnet/Akka.TestKit.NUnit/issues/44 for details. \ No newline at end of file +- Support for Akka 1.4.39 +- Support for NUnit 3.13.3 +- Now targets `netstandard2.0` +- All `TestKit` classes now implement `[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]` which guarantees a unique `ActorSystem` instance per-run. All previous TestKit hacks needed to support this are now removed. See [#44](https://github.com/akkadotnet/Akka.TestKit.NUnit/issues/44) for details. diff --git a/src/Akka.TestKit.NUnit.Tests/Akka.TestKit.NUnit.Tests.csproj b/src/Akka.TestKit.NUnit.Tests/Akka.TestKit.NUnit.Tests.csproj index bf6fe96..d760cfb 100644 --- a/src/Akka.TestKit.NUnit.Tests/Akka.TestKit.NUnit.Tests.csproj +++ b/src/Akka.TestKit.NUnit.Tests/Akka.TestKit.NUnit.Tests.csproj @@ -1,21 +1,12 @@ - - Akka.TestKit.NUnit.Tests - net6.0 + net6.0;net462 - - - - - - - + + + + - - - $(DefineConstants);RELEASE - - \ No newline at end of file + diff --git a/src/Akka.TestKit.NUnit/Akka.TestKit.NUnit.csproj b/src/Akka.TestKit.NUnit/Akka.TestKit.NUnit.csproj index 0374ce2..7b3477d 100644 --- a/src/Akka.TestKit.NUnit/Akka.TestKit.NUnit.csproj +++ b/src/Akka.TestKit.NUnit/Akka.TestKit.NUnit.csproj @@ -1,16 +1,13 @@  - Akka.TestKit.NUnit - netstandard2.0 - true + + net6.0;net462 + true - + + - - - $(DefineConstants);RELEASE - diff --git a/src/Akka.TestKit.NUnit/NUnitAssertions.cs b/src/Akka.TestKit.NUnit/NUnitAssertions.cs index 3449658..a730e24 100644 --- a/src/Akka.TestKit.NUnit/NUnitAssertions.cs +++ b/src/Akka.TestKit.NUnit/NUnitAssertions.cs @@ -18,33 +18,27 @@ public class NUnitAssertions : ITestKitAssertions public void Fail(string format = "", params object[] args) { - Assert.Fail(format, args); + Assert.Fail(string.Format(format, args)); } public void AssertTrue(bool condition, string format = "", params object[] args) { - Assert.IsTrue(condition, format, args); + Assert.That(condition, Is.True, string.Format(format, args)); } public void AssertFalse(bool condition, string format = "", params object[] args) { - Assert.IsFalse(condition, format, args); + Assert.That(condition, Is.False, string.Format(format, args)); } public void AssertEqual(T expected, T actual, string format = "", params object[] args) { - Assert.AreEqual(expected, actual, format, args); + Assert.That(actual, Is.EqualTo(expected), string.Format(format, args)); } public void AssertEqual(T expected, T actual, Func comparer, string format = "", params object[] args) { - if (!comparer(expected, actual)) - throw new AssertionException($"Assert.AreEqual failed. Expected [{FormatValue(expected)}]. Actual [{FormatValue(actual)}]. {string.Format(format, args)}"); - } - - private static string FormatValue(T expected) - { - return ReferenceEquals(expected, null) ? "null" : expected.ToString(); + Assert.That(actual, Is.EqualTo(expected).Using(comparer), string.Format(format, args)); } } -} \ No newline at end of file +} diff --git a/src/Akka.TestKit.NUnit3.Tests/Akka.TestKit.NUnit3.Tests.csproj b/src/Akka.TestKit.NUnit3.Tests/Akka.TestKit.NUnit3.Tests.csproj index b3d40d0..e4d6179 100644 --- a/src/Akka.TestKit.NUnit3.Tests/Akka.TestKit.NUnit3.Tests.csproj +++ b/src/Akka.TestKit.NUnit3.Tests/Akka.TestKit.NUnit3.Tests.csproj @@ -1,21 +1,12 @@ - - Akka.TestKit.NUnit3.Tests - net6.0 + net6.0;net462 - - - - - - - + + + + - - - $(DefineConstants);RELEASE - - \ No newline at end of file + diff --git a/src/Akka.TestKit.NUnit3/Akka.TestKit.NUnit3.csproj b/src/Akka.TestKit.NUnit3/Akka.TestKit.NUnit3.csproj index a940f54..dfba4fd 100644 --- a/src/Akka.TestKit.NUnit3/Akka.TestKit.NUnit3.csproj +++ b/src/Akka.TestKit.NUnit3/Akka.TestKit.NUnit3.csproj @@ -1,17 +1,15 @@  - - Akka.TestKit.NUnit + netstandard2.0 - true + true - + + - - - $(DefineConstants);RELEASE - diff --git a/src/Akka.TestKit.NUnit3/NUnitAssertions.cs b/src/Akka.TestKit.NUnit3/NUnitAssertions.cs index 5814cb1..421c78e 100644 --- a/src/Akka.TestKit.NUnit3/NUnitAssertions.cs +++ b/src/Akka.TestKit.NUnit3/NUnitAssertions.cs @@ -8,6 +8,8 @@ using System; using NUnit.Framework; +#pragma warning disable NUnit2050 // NUnit 4 no longer supports string.Format specification + namespace Akka.TestKit.NUnit3 { /// @@ -23,28 +25,22 @@ public void Fail(string format = "", params object[] args) public void AssertTrue(bool condition, string format = "", params object[] args) { - Assert.IsTrue(condition, format, args); + Assert.That(condition, Is.True, format, args); } public void AssertFalse(bool condition, string format = "", params object[] args) { - Assert.IsFalse(condition, format, args); + Assert.That(condition, Is.False, format, args); } public void AssertEqual(T expected, T actual, string format = "", params object[] args) { - Assert.AreEqual(expected, actual, format, args); + Assert.That(actual, Is.EqualTo(expected), format, args); } public void AssertEqual(T expected, T actual, Func comparer, string format = "", params object[] args) { - if (!comparer(expected, actual)) - throw new AssertionException($"Assert.AreEqual failed. Expected [{FormatValue(expected)}]. Actual [{FormatValue(actual)}]. {string.Format(format, args)}"); - } - - private static string FormatValue(T expected) - { - return ReferenceEquals(expected, null) ? "null" : expected.ToString(); + Assert.That(actual, Is.EqualTo(expected).Using(comparer), format, args); } } -} \ No newline at end of file +} diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 0a8a817..ae005da 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,23 +1,43 @@ - - Copyright © 2013-2022 - Akka.NET Contrib - TestKit for writing tests for Akka.NET using NUnit. - 1.5.0 - • Support for Akka 1.4.39 - • Support for NUnit 3.13.3 - • Now targets netstandard2.0 - • All TestKit classes now implement [FixtureLifeCycle(LifeCycle.InstancePerTestCase)] which guarantees a unique ActorSystem instance per-run. All previous TestKit hacks needed to support this are now removed. See https://github.com/akkadotnet/Akka.TestKit.NUnit/issues/44 for details. - akka;actors;actor model;Akka;concurrency;testkit;nunit - true - http://getakka.net/images/akkalogo.png - https://github.com/AkkaNetContrib/Akka.TestKit.Nunit - https://github.com/AkkaNetContrib/Akka.TestKit.Nunit - $(NoWarn);CS1591 - - - 3.14.0 - 4.5.0 - 1.5.26 - - \ No newline at end of file + + Copyright © 2013-$([System.DateTime]::Now.Year) + Akka.NET Contrib + TestKit for writing tests for Akka.NET using NUnit. + 1.6.0 + preview.1 + $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../../RELEASE_NOTES.md").Substring(0,567)) + akka;actors;actor model;Akka;concurrency;testkit;nunit + true + akka.png + https://github.com/AkkaNetContrib/Akka.TestKit.Nunit + Apache-2.0 + README.md + $(NoWarn);CS1591 + 10.0 + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true + true + + + 1.5.28 + 17.11.1 + 3.14.0 + 4.2.2 + 4.3.0 + 4.6.0 + + + $(DefineConstants);RELEASE + + + + + + + + diff --git a/src/akka.png b/src/akka.png new file mode 100644 index 0000000000000000000000000000000000000000..ae64ad1e5e84be0508059f1564906eed11398dce GIT binary patch literal 2338 zcma)8i#OAa8~@JMm`q-jyHr1yAo$LPew>lX8hQHRU#UCd{Qmq>#&7uUr-h zWo+%$^xATpOQ@}sy)HxTMbq%=KX}jie4fua&w0*yp3ig6bIz0Le(E?}UQ-?b0Jzf$ zhtpe{^ow%Pt;n(s=-m=n#0eh~04Oql5!7}&OauUOJSPYHv(e+C2XR!-ZXLEyl$u&Z zx0(07Ln#i9nQe9Muf{3_Di;E&JF}mCUOPVENLGDY8+zbaAmr@Dh@Dj))By+HI3zsG z*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