Xunit.Extensions.Ordering 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Xunit.Extensions.Ordering --version 1.1.1
NuGet\Install-Package Xunit.Extensions.Ordering -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xunit.Extensions.Ordering" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xunit.Extensions.Ordering --version 1.1.1
#r "nuget: Xunit.Extensions.Ordering, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xunit.Extensions.Ordering as a Cake Addin
#addin nuget:?package=Xunit.Extensions.Ordering&version=1.1.1

// Install Xunit.Extensions.Ordering as a Cake Tool
#tool nuget:?package=Xunit.Extensions.Ordering&version=1.1.1

Xunit.Extensions.Ordering

Xunit extension for ordered (integration) testing

Nuget: https://www.nuget.org/packages/Xunit.Extensions.Ordering/

There is very limiting space for adding support of ordered (integration) testing into xunit without rewriting runner.

Usage:

  1. Add AssemblyInfo.cs with only following lines of code
using Xunit;

//Optional
[assembly: CollectionBehavior(DisableTestParallelization = true)]
//Optional
[assembly: TestCaseOrderer("Xunit.Extensions.Ordering.TestCaseOrderer", "Xunit.Extensions.Ordering")]
//Optional
[assembly: TestCollectionOrderer("Xunit.Extensions.Ordering.CollectionOrderer", "Xunit.Extensions.Ordering")]
  1. Add Order Attribute to test classes and methods. Tests are executed in ascending order. If no Order attribute is specified default 0 is assigned. Multiple Order attributes can have same value. Their execution order in this case is deterministic but unpredictible.
[Order(1)]
public class TC2
{
	[Fact, Order(2)]
	public void M1() { Assert.Equal(2, Counter.Next()); }

	[Fact, Order(3)]
	public void M2() { Assert.Equal(3, Counter.Next()); }

	[Fact, Order(1)]
	public void M3() { Assert.Equal(1, Counter.Next()); }
}
  1. You can enable warning messaging about continuity and duplicates of Order indexes by enabling diagnosticMessages.

    1. Create xnuit.runner.json in root of your test project
     {
     	"$schema": "https://xunit.github.io/schema/current/xunit.runner.schema.json",
     	"diagnosticMessages": true
     }
    
    1. Set "Copy to output directory" for this file in visual studio to "Copy if newer"
    2. In the Output Visual Studio window choose "Tests" option in the "Show output from" dropdown
    3. You will see warnings like
     Missing test case order sequence from '3' to '19' for tc [Xunit.Extensions.Ordering.Tests.TC1.M2]
    
  2. There are limitations when you need to use collections. You have to use collection per class like in the sample bottom bcs. of litimations of Xunit (you cannot order test cases in a collection without massive rewrite of runner infrastructure of xunit)

[CollectionDefinition("COL1"), Collection("COL1"), Order(3)]
public class TC1
{
	[Fact, Order(2)]
	public void M1() { Assert.Equal(...); }

	[Fact, Order(3)]
	public void M2() { Assert.Equal(...); }

	[Fact, Order(1)]
	public void M3() { Assert.Equal(...); }
}
  1. If you need to split facts into multiple test clases use partial classes 😃 Finally following this design there is no real difference between CollectionFixture and ClassFixture 😦

  2. If you need assembly level Fixtures in both scenarios use this https://github.com/xunit/samples.xunit/tree/master/AssemblyFixtureExample 😃

Product 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 netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.2

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Xunit.Extensions.Ordering:

Package Downloads
Refactorius.Data.Xunit

The MS SQL database enabing xUnit extension library.

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on Xunit.Extensions.Ordering:

Repository Stars
AvaloniaUI/Avalonia
Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET Foundation community project.
VirtoCommerce/vc-platform
Virto Commerce B2B Innovation Platform
linvi/tweetinvi
Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
JJConsulting/JJMasterData
.NET CRUD generator library with Bootstrap support to create dynamic forms at runtime from a data dictionary.
Hitmasu/Jitex
A library to modify MSIL and native code at runtime
Version Downloads Last updated
1.4.5 3,683,780 2/11/2019
1.4.4 1,782 2/10/2019
1.4.3 1,419 2/10/2019
1.4.2 1,399 2/10/2019
1.4.1 1,366 2/10/2019
1.4.0 5,058 2/9/2019
1.3.1 1,586 2/9/2019
1.3.0 1,252 2/8/2019
1.2.3 1,241 2/7/2019
1.2.2 1,423 2/6/2019
1.2.1 1,261 2/6/2019
1.1.1 1,310 2/4/2019
1.1.0 1,229 2/4/2019
1.0.1 1,255 2/4/2019

Support for continuity of order sequence checking and writing warning notifications to test output
Support for duplicate order indexes checking and writing warning notifications to test output