Toolbelt.NUnit.TestName
1.0.1
dotnet add package Toolbelt.NUnit.TestName --version 1.0.1
NuGet\Install-Package Toolbelt.NUnit.TestName -Version 1.0.1
<PackageReference Include="Toolbelt.NUnit.TestName" Version="1.0.1" />
paket add Toolbelt.NUnit.TestName --version 1.0.1
#r "nuget: Toolbelt.NUnit.TestName, 1.0.1"
// Install Toolbelt.NUnit.TestName as a Cake Addin #addin nuget:?package=Toolbelt.NUnit.TestName&version=1.0.1 // Install Toolbelt.NUnit.TestName as a Cake Tool #tool nuget:?package=Toolbelt.NUnit.TestName&version=1.0.1
Test Name for NUnit
Summary
This package provides test attributes that alternate NUnit's [Test]
and [TestCaseSource]
attribute to add TestName
property.
Before:
After:
How to use
- Add package to your project like this.
dotnet add package Toolbelt.NUnit.TestName
- Add two
global using ...
statements in theUsings.cs
C# source code file in the NUnit test project.
/* 📜 "Usings.cs" */
global using NUnit.Framework;
// 👇 Add these tow lines.
global using Test = Toolbelt.NUnit.TestName.TestAttribute;
global using TestCaseSource = Toolbelt.NUnit.TestName.TestCaseSourceAttribute;
- After doing the above step, You will see the compile errors like below if you have already implemented some test methods.
error CS1614: 'Test' is ambiguous between 'TestAttribute' and 'TestAttribute'. Either use '@Test' or explicitly include the 'Attribute' suffix.
error CS1614: 'TestCaseSource' is ambiguous between 'TestCaseSourceAttribute' and 'TestCaseSourceAttribute'. Either use '@TestCaseSource' or explicitly include the 'Attribute' suffix.
- If so, please replace existing
[Test]
to[@Test]
and replace existing[TestCaseSource]
to[@TestCaseSource]
. And later, please use[@Test]
instead of[Test]
, and use[@TestCaseSource]
instead of[TestCaseSource]
. In short, please make those test attribute names start with@
.
[@Test] // 👈 Use [@Test] instead of [Test]
public void MyTestMethod() {
...
[@TestCaseSource("...")] // 👈 Use [@TestCaseSource] instead of [TestCaseSource]
public void MyTestCasesMethod(...) {
...
- Finally, you can use the
TestName
attribute in[@Test]
and[@TestCaseSource]
attributes to show more readable test names in a display such as Visual Studio Test Explorer or thedotnet test
command.
// 👇 You can use the "TestName" property.
[@Test(TestName = "...")]
public void MyTestMethod() {
...
// 👇 You can use the "TestName" property.
[@TestCaseSource("...", TestName = "...")]
public void MyTestCasesMethod(...) {
...
Aside: Why doesn't this package provide the TestCase
attribute?
Because the TestCase
attribute in NUnit already has the TestName
property.
Honestly, I don't know why NUnit doesn't provide the TestName
property on the Test
and TestCaseSource
attributes.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- NUnit (>= 3.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Toolbelt.NUnit.TestName:
Repository | Stars |
---|---|
jsakamoto/Toolbelt.Blazor.HeadElement
Head element support (change the document title, "meta" elements such as OGP, and "link" elements) for Blazor apps.
|
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 711 | 9/24/2022 |
v.1.0.1
- Fix: incorrect the package project URL.
To see all the change logs, please visit the following URL.
- https://github.com/jsakamoto/Toolbelt.NUnit.TestName/blob/main/RELEASE-NOTES.txt