xchain 0.1.0-main.4

This is a prerelease version of xchain.
There is a newer version of this package available.
See the version list below for details.
dotnet add package xchain --version 0.1.0-main.4
                    
NuGet\Install-Package xchain -Version 0.1.0-main.4
                    
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="xchain" Version="0.1.0-main.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="xchain" Version="0.1.0-main.4" />
                    
Directory.Packages.props
<PackageReference Include="xchain" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add xchain --version 0.1.0-main.4
                    
#r "nuget: xchain, 0.1.0-main.4"
                    
#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.
#:package xchain@0.1.0-main.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=xchain&version=0.1.0-main.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=xchain&version=0.1.0-main.4&prerelease
                    
Install as a Cake Tool

Xchain

Build NuGet

Xchain extends xUnit with a fluent mechanism to chain tests, pass data between them, and skip dependent tests if earlier ones fail. It improves test readability and flow control when writing integration or system-level tests that have interdependencies.

Key Features

  • Custom test ordering via [Link(order)]
  • Shared output across chained tests using TestChainFixture
  • Failure-aware execution — skip dependent tests if prior ones failed
  • Automatic exception capture for reporting/debugging

This demonstrates using the LinkOrderer to control test run sequence based on the provided order value.

[TestCaseOrderer("Xchain.LinkOrderer", "Xchain")]
public class ChainTest
{
    [Fact, Link(1)] public void Test1() => Thread.Sleep(1000);
    [Fact, Link(3)] public void Test2() => Thread.Sleep(3000);
    [Fact, Link(2)] public void Test3() => Thread.Sleep(2000);
}

➡️ What it shows: Tests will run in the order 1 → 3 → 2 based on their [Link(x)] values, not alphabetically or by name.

🧪 Example 2: Sharing Data with TestChainFixture

This example shows how test output values and errors can be shared across test methods using the fixture.

[TestCaseOrderer("Xchain.LinkOrderer", "Xchain")]
public class ChainTest(TestChainFixture testChain) : IClassFixture<TestChainFixture>
{
    [Fact, Link(3)]
    public void Test1() => testChain.Errors.Push(new NotImplementedException());

    [Fact, Link(2)]
    public void Test2()
    {
        var sleep = (int)testChain.Output["Sleep"];
        Thread.Sleep(sleep);
    }

    [Fact, Link(1)]
    public void Test3()
    {
        var sleep = 1000;
        testChain.Output["Sleep"] = sleep * 2;
        Thread.Sleep(sleep);
    }
}

➡️ What it shows:

  • Test3 sets shared output.
  • Test2 reads that output and uses it.
  • Test1 pushes an error manually to simulate a failure.

This uses the fluent API to automatically skip tests based on prior failures.

[TestCaseOrderer("Xchain.LinkOrderer", "Xchain")]
public class ChainTest(TestChainFixture chain) : IClassFixture<TestChainFixture>
{
    [ChainFact, Link(3)]
    public void Test1() => chain.LinkUnless<Exception>((output) =>
    {
        throw new NotImplementedException();
    });


    [ChainFact, Link(2)]
    public void Test2() => chain.LinkUnless<NotImplementedException>((output) =>
    {
        var sleep = output.Get<int>("Sleep");
        Thread.Sleep(sleep);
    });
    

    [ChainFact, Link(1)]
    public void Test3() => chain.Link((output) =>
    {
        var sleep = 1000;
        Thread.Sleep(sleep);
        output["Sleep"] = sleep * 2;

        throw new TimeoutException();
    });
}

➡️ What it shows:

  • LinkUnless<T> skips the test if a matching exception occurred earlier.
  • Link captures and records exceptions for dependent tests to react to.

Created from JandaBox Box icon created by Freepik - Flaticon

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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. 
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
0.4.0 463 6/29/2025
0.3.5-try-output.7 120 6/18/2025
0.3.5-try-output.2 121 6/18/2025
0.3.5-main.2 74 6/29/2025
0.3.5-main.1 122 6/18/2025
0.3.5-collection-link.18 69 6/29/2025
0.3.5-collection-link.17 71 6/29/2025
0.3.5-collection-link.12 285 6/19/2025
0.3.5-collection-link.6 119 6/18/2025
0.3.5-collection-link.5 117 6/18/2025
0.3.4 146 6/18/2025
0.3.4-test-output.3 118 6/18/2025
0.3.4-test-output.2 119 6/18/2025
0.3.4-test-output.1 121 6/18/2025
0.3.4-main.1 118 6/18/2025
0.3.3 231 6/16/2025
0.3.3-main.1 121 6/16/2025
0.3.3-chain-linker.7 129 6/16/2025
0.3.2 230 6/13/2025
0.3.2-main.2 194 6/13/2025
0.3.2-flow-fact.3 238 6/13/2025
0.3.2-chain-linker.6 263 6/11/2025
0.3.1 308 5/26/2025
0.3.1-skipped-reason-emoji.1 128 5/26/2025
0.3.1-main.1 126 5/26/2025
0.3.0 154 5/26/2025
0.2.2-main.1 129 5/26/2025
0.2.2-chain-name-and-order.7 80 5/25/2025
0.2.2-chain-name-and-order.5 46 5/24/2025
0.2.1 158 5/22/2025
0.2.1-trait-discoverer.1 120 5/21/2025
0.2.1-main.1 122 5/22/2025
0.2.0 165 5/19/2025
0.1.0 162 5/18/2025
0.1.0-test-chain.3 127 5/18/2025
0.1.0-main.4 123 5/18/2025
0.1.0-main.2 129 5/18/2025
0.1.0-ci.1 125 5/18/2025
0.1.0-chain-orderer.3 123 5/18/2025