kwld.Xunit.Ordering 1.0.0

dotnet add package kwld.Xunit.Ordering --version 1.0.0                
NuGet\Install-Package kwld.Xunit.Ordering -Version 1.0.0                
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="kwld.Xunit.Ordering" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add kwld.Xunit.Ordering --version 1.0.0                
#r "nuget: kwld.Xunit.Ordering, 1.0.0"                
#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 kwld.Xunit.Ordering as a Cake Addin
#addin nuget:?package=kwld.Xunit.Ordering&version=1.0.0

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

Xunit simple ordering

A small project to order xUnit tests.

Simple Xunit test ordering, where the order is defined by the test-class, unit test declaration order.

src / nuget

Usage

using kwld.Xunit.Ordering;

/// <summary>
/// Add <see cref="TestCaseOrdererAttribute"/> to use the line orderer
/// </summary>
[TestCaseOrderer(LineOrderedTests.TypeName, LineOrderedTests.AssemName)]
public class UsageExample(UsageExample.State state): IClassFixture<UsageExample.State>
{
    public class State { public int Counter; }

    /// <summary>
    /// Add <see cref="OrderedAttribute"/> to include in sort order.
    /// First declared ordered test runs first.
    /// </summary>
    [Ordered, Fact]
    public void Test1()
    {
        Assert.Equal(1, state.Counter++);
    }

    /// <summary>
    /// Ordering for a Theory matches the order of generated
    /// tests.
    /// </summary>
    [Ordered, Theory]
    [InlineData(2)]
    [InlineData(3)]
    public void Test2(int expected)
    {
        Assert.Equal(expected, state.Counter++);
    }

    /// <summary>
    /// Tests without <see cref="OrderedAttribute"/> run first
    /// </summary>
    [Fact]
    public void TestUnordered()
    {
        Assert.Equal(0, state.Counter++);
    }

Why?

There are more feature rich xunit ordering packages out there, such as Xunit.Extensions.Ordering and Dangl.Xunit.Extensions.Ordering

But sometimes; a simpler approach that fits can be easier to work with.

This adds a simple OrderedAttribute that records the test method's line-number. This is then used to sort test from top to bottom (declaration order).

This package only handles ordering per test-class; and is focused on ordering based on test method declaration order.

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 93 10/26/2024
1.0.0-preview1 143 4/24/2024

Simple xunit test ordering based on declaration order.