Pro.NBench.xUnit
1.0.5
See the version list below for details.
dotnet add package Pro.NBench.xUnit --version 1.0.5
NuGet\Install-Package Pro.NBench.xUnit -Version 1.0.5
<PackageReference Include="Pro.NBench.xUnit" Version="1.0.5" />
paket add Pro.NBench.xUnit --version 1.0.5
#r "nuget: Pro.NBench.xUnit, 1.0.5"
// Install Pro.NBench.xUnit as a Cake Addin
#addin nuget:?package=Pro.NBench.xUnit&version=1.0.5
// Install Pro.NBench.xUnit as a Cake Tool
#tool nuget:?package=Pro.NBench.xUnit&version=1.0.5
Pro.NBench.xUnit
A project to allow NBench tests to be discovered, executed, reported, and debugged using xUnit in ReSharper, and to a less polished extent, in Visual Studio Test Explorer. This allows you to not only test business logic validity, but also set performance criteria as part of your test suite.
Please refer to the Introduction to NBench as a starting point for information on how to configure NBench Tests and Measurements.
Installation
To install Pro.NBench.xUnit (Integration of NBench, xUnit and ReSharper / Visual Studio Test Explorer), run the following command in the Package Manager Console
Install-Package Pro.NBench.xUnit
Usage
The Tests project serves as an example, and contains a set of three standard NBench test classes, attributed to collect Measurements, and Assert some conditions.
Step 1.
Disable xUnit parrallelized execution, at either the Assembly, or Collection level. In the example, this is achived by adding the following line within the project:
[assembly: CollectionBehavior(DisableTestParallelization = true)]
Step 2.
Add a reference to the Pro.NBench.xUnit assembly, and include the following using statement for each class:
using Pro.NBench.xUnit.XunitExtensions;
Step 3.
Include a constructor that includes a paramater of type ITestOutputHelper, and creates a new XunitTrace listener, as follows:
public DictionaryMemoryTests(ITestOutputHelper output)
{
Trace.Listeners.Clear();
Trace.Listeners.Add(new XunitTraceListener(output));
}
Step 4.
Annotate each NBench test with the following attribute:
[NBenchFact]
You can also use xUnit Theories, by adding:
[NBenchTheory]
The NBench Tests will be discovered and displayed in either the Resharper or Visual Studio Test Runners.
Breakpoints in the NBench benchmarks are fully supported for debugging.
Please note, it is important that for accurate benchhmarking purposes, that the Tests are run in Release configuration, to allow compiler optimisations to be applied.
When executed using ReSharper, the Tests are displayed, with the result of NBench Assertions, and any Measurements reported by each Test.
Visual Studio Test Explorer will also execute and debug the Tests, but presentation of results is less polished.
Please note, the example includes a variety of passing, and a deliberately failing Test.
Future plans
Release as NuGet package.
Integration with xUnit Theories, to support paramaterised tests.
VS 2017, VS 2019 and JetBrains Rider support.
Possibly standard NBench Markdown Report output.
Possibly a Visual Studio Template for a pre-configured Test Project and Test Class.
-- All Feedback Welcome!
David Paul McQuiggin, Pro-Coded.
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 | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.6 is compatible. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.6
- NBench (>= 1.2.2)
- NETStandard.Library (>= 1.6.1)
- System.Diagnostics.TraceSource (>= 4.3.0)
- System.Reflection.Emit.ILGeneration (>= 4.3.0)
- System.Reflection.Emit.Lightweight (>= 4.3.0)
- xunit (>= 2.4.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Pro.NBench.xUnit:
Package | Downloads |
---|---|
SharpPulsar
SharpPulsar is Apache Pulsar Client built using Akka.net |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on Pro.NBench.xUnit:
Repository | Stars |
---|---|
RicoSuter/NJsonSchema
JSON Schema reader, generator and validator for .NET
|
|
AElfProject/AElf
A scalable cloud computing blockchain platform
|
|
RicoSuter/Namotion.Reflection
.NET library with advanced reflection APIs.
|