Ardalis.SingleFileTestRunner.xUnitV3 1.1.0

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

SingleFileTestRunner

NuGet NuGet Downloads

A lightweight package for running xUnit v3 tests in single-file C# applications. Perfect for quick test scripts, learning scenarios, or standalone test executables.

Installation

dotnet add package Ardalis.SingleFileTestRunner.xUnitV3
dotnet add package xunit.v3

Quick Start

Create a single .cs file with your tests and run them directly:

// MyTests.cs
using Xunit;
using Ardalis.SingleFileTestRunner;

// Run all tests in this file
return await TestRunner.RunTestsAsync();

// Your test classes
public class CalculatorTests
{
    [Fact]
    public void Addition_ReturnsCorrectSum()
    {
        Assert.Equal(4, 2 + 2);
    }

    [Theory]
    [InlineData(1, 1, 2)]
    [InlineData(5, 3, 8)]
    [InlineData(-1, 1, 0)]
    public void Addition_WithVariousInputs_ReturnsExpectedResult(int a, int b, int expected)
    {
        Assert.Equal(expected, a + b);
    }
}

public class StringTests
{
    [Fact]
    public void Contains_FindsSubstring()
    {
        Assert.Contains("world", "Hello world!");
    }
}

Run with:

dotnet run MyTests.cs

Features

  • Simple API: Just call TestRunner.RunTestsAsync() to discover and run all xUnit tests
  • Colorized Output: Clear visual feedback with green for passing, red for failing, and yellow for skipped tests
  • CI/CD Ready: Returns exit code 0 for success, 1 for failures
  • Single-File Compatible: Works with dotnet run on single .cs files and published single-file executables
  • Full xUnit Support: Supports [Fact], [Theory], and all standard xUnit attributes

Sample Output

Discovering and running tests...

  [PASS] CalculatorTests.Addition_ReturnsCorrectSum
  [PASS] CalculatorTests.Addition_WithVariousInputs_ReturnsExpectedResult(a: 1, b: 1, expected: 2)
  [PASS] CalculatorTests.Addition_WithVariousInputs_ReturnsExpectedResult(a: 5, b: 3, expected: 8)
  [PASS] CalculatorTests.Addition_WithVariousInputs_ReturnsExpectedResult(a: -1, b: 1, expected: 0)
  [PASS] StringTests.Contains_FindsSubstring

Test run completed in 0.15s
Total tests: 5
  Passed: 5

Use Cases

  • Learning & Experimentation: Quickly test C# concepts without setting up a full test project
  • Script-Based Testing: Create standalone test scripts that can be shared and run easily
  • Single-File Deployments: Build self-contained test executables for distribution
  • Prototyping: Rapidly prototype and validate code in a single file
  • Parallel Testing: Run many test files in completely standalone processes, in parallel

Requirements

  • .NET 10.0 or later
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
1.1.0 182 12/4/2025
1.0.0 183 12/4/2025

* Add PrivateAssets none for xUnit.v3 dependencies