xUnitV3LoadFramework 2.0.0.27

dotnet add package xUnitV3LoadFramework --version 2.0.0.27
                    
NuGet\Install-Package xUnitV3LoadFramework -Version 2.0.0.27
                    
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="xUnitV3LoadFramework" Version="2.0.0.27" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="xUnitV3LoadFramework" Version="2.0.0.27" />
                    
Directory.Packages.props
<PackageReference Include="xUnitV3LoadFramework" />
                    
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 xUnitV3LoadFramework --version 2.0.0.27
                    
#r "nuget: xUnitV3LoadFramework, 2.0.0.27"
                    
#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 xUnitV3LoadFramework@2.0.0.27
                    
#: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=xUnitV3LoadFramework&version=2.0.0.27
                    
Install as a Cake Addin
#tool nuget:?package=xUnitV3LoadFramework&version=2.0.0.27
                    
Install as a Cake Tool

xUnitV3LoadFramework

Make your tests super fast! 🚀

Think of this like having many people test your website at the same time to see if it can handle lots of visitors - just like when everyone tries to buy concert tickets at once!

NuGet Downloads .NET 8 xUnit v3 License: MIT

What does it do?

  • Easy to use - Just add one line to your test and it becomes a speed test!
  • Many tests at once - Like having 100 people click your button at the same time
  • Shows you numbers - Tells you how fast your app is and if anything breaks
  • Works with xUnit - Uses the tests you already know how to write

Quick Start

1. Install it

dotnet add package xUnitV3LoadFramework

2. Write a simple test

Method 1: Using an attribute (like a sticker on your test)

using xUnitV3LoadFramework.Attributes;
using xUnitV3LoadFramework.Extensions;

public class MyTests
{
    private readonly HttpClient _httpClient = new HttpClient();

    [Load(concurrency: 5, duration: 3000, interval: 500)] // 5 people testing for 3 seconds
    public async Task Test_My_Website()
    {
        var result = await LoadTestRunner.ExecuteAsync(async () =>
        {
            var response = await _httpClient.GetAsync("https://api.example.com/data");
            response.EnsureSuccessStatusCode();
            return true; // Return true for success
        });
        
        Assert.True(result.Success > 0, "Should have successful executions");
    }
}

Method 2: Using fluent API (like building with blocks)

using xUnitV3LoadFramework.Extensions;

public class MyFluentTests
{
    private readonly HttpClient _httpClient = new HttpClient();

    [Fact]
    public async Task Test_With_Fluent_API()
    {
        var result = await LoadTestRunner.Create()
            .WithName("My_Cool_Test")
            .WithConcurrency(10)        // 10 people
            .WithDuration(5000)         // for 5 seconds  
            .WithInterval(200)          // pause 200ms between batches
            .RunAsync(async () =>
            {
                var response = await _httpClient.GetAsync("https://api.example.com");
                response.EnsureSuccessStatusCode();
                // No need to return anything - success is assumed if no exception
            });

        Assert.True(result.Success > 0, "Should have successful executions");
        Console.WriteLine($"Success rate: {result.Success}/{result.Total}");
    }
}

3. See the results

✅ Test Results:
   Total tests: 50
   Successful: 48
   Failed: 2
   Speed: 16 tests per second
   Time taken: 3.2 seconds

🤔 Which method should I use?

Use Method 1 (Load attribute) when:

  • You want the framework to automatically discover and run your load tests
  • You prefer attribute-based configuration

Use Method 2 (Fluent API) when:

  • You want more control over when and how the load test runs
  • You prefer explicit configuration in your test code
  • You want to mix regular xUnit tests with load tests in the same class

💡 More Examples

Mixed testing (both regular and load tests):

public class MixedTests
{
    private readonly HttpClient _httpClient = new HttpClient();

    [Fact] // Regular xUnit test
    public async Task Regular_Test()
    {
        var response = await _httpClient.GetAsync("https://api.example.com");
        Assert.True(response.IsSuccessStatusCode);
    }

    [Fact] // Load test using fluent API
    public async Task Load_Test_Using_Fluent_API()
    {
        var result = await LoadTestRunner.Create()
            .WithConcurrency(5)
            .WithDuration(2000)
            .RunAsync(async () =>
            {
                var response = await _httpClient.GetAsync("https://api.example.com");
                response.EnsureSuccessStatusCode();
            });

        Assert.True(result.Success > 0);
    }
}

Advanced load testing with explicit success/failure:

[Fact]
public async Task Advanced_Load_Test_With_Custom_Success_Logic()
{
    var result = await LoadTestRunner.Create()
        .WithName("Advanced_API_Test")
        .WithConcurrency(10)
        .WithDuration(5000)
        .WithInterval(100)
        .RunAsync(async () =>
        {
            var response = await _httpClient.GetAsync("https://api.example.com/data");
            
            if (!response.IsSuccessStatusCode) 
                return false;
                
            var content = await response.Content.ReadAsStringAsync();
            return !string.IsNullOrEmpty(content); // Custom success logic
        });

    Assert.True(result.Success > result.Total * 0.8, "Should have 80%+ success rate");
    Console.WriteLine($"Achieved {result.RequestsPerSecond:F2} requests per second");
}

Want to see what's happening? Use logs! 📝

Add this to see detailed logs with xUnit.OTel:

// Add to your test project
services.AddOTelDiagnostics();

This shows you exactly what your tests are doing, like a diary of your test!

What the numbers mean

  • concurrency: How many people test at the same time (like 5 friends)
  • duration: How long the test runs (like counting to 3000)
  • Success/Failed: How many tests worked vs broke
  • Speed: How fast your app can handle requests

Requirements

  • .NET 8.0 or newer
  • xUnit v3 for testing

Need help?


Made with ❤️ by Vasyl to help make apps faster!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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
2.0.0.27 339 8/5/2025
2.0.0.22 111 8/3/2025
2.0.0.21 110 8/3/2025
2.0.0.20 109 8/3/2025
2.0.0.19 113 8/3/2025
1.0.0.95 22 8/2/2025
1.0.0.94 21 8/1/2025
1.0.0.93 27 8/1/2025
1.0.0.92 101 7/29/2025
1.0.0.91 94 7/28/2025
1.0.0.90 91 7/28/2025
1.0.0.87 315 7/25/2025
1.0.0.86 315 7/25/2025
1.0.0.85 443 7/24/2025
1.0.0.84 438 7/24/2025
1.0.0.83 490 7/23/2025
1.0.0.81 491 7/22/2025
1.0.0.80 487 7/22/2025
1.0.0.79 493 7/22/2025
1.0.0.78 493 7/22/2025
1.0.0.77 494 7/22/2025
1.0.0.76 143 7/7/2025
1.0.0.75 137 7/7/2025
1.0.0.74 74 7/5/2025
1.0.0.73 247 5/12/2025
1.0.0.72 199 5/11/2025
1.0.0.71 191 5/11/2025
1.0.0.70 92 5/9/2025
1.0.0.69 90 5/9/2025
1.0.0.68 88 5/9/2025
1.0.0.67 95 5/9/2025
1.0.0.66 98 5/9/2025
1.0.0.65 101 5/9/2025
1.0.0.64 139 5/9/2025
1.0.0.63 145 5/9/2025
1.0.0.62 153 4/30/2025
1.0.0.61 151 4/30/2025
1.0.0.60 150 4/30/2025
1.0.0.57 152 4/30/2025

Version 2.0.0: Full xUnit v3 compatibility, fluent API, enhanced performance metrics, and production-ready features. See CHANGELOG.md for complete details.