Xunit.Extensions.Ordering 1.1.1

.NET Core 2.2
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, C# scripting and .NET Interactive. 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 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.


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

[assembly: CollectionBehavior(DisableTestParallelization = true)]
[assembly: TestCaseOrderer("Xunit.Extensions.Ordering.TestCaseOrderer", "Xunit.Extensions.Ordering")]
[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.
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 Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
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

The MS SQL database enabing xUnit extension library.

GitHub repositories (3)

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

Repository Stars
A cross-platform UI framework for .NET
VirtoCommerce Platform repository
Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
Version Downloads Last updated
1.4.5 1,764,143 2/11/2019
1.4.4 929 2/10/2019
1.4.3 606 2/10/2019
1.4.2 596 2/10/2019
1.4.1 589 2/10/2019
1.4.0 687 2/9/2019
1.3.1 558 2/9/2019
1.3.0 503 2/8/2019
1.2.3 517 2/7/2019
1.2.2 663 2/6/2019
1.2.1 528 2/6/2019
1.1.1 539 2/4/2019
1.1.0 507 2/4/2019
1.0.1 511 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