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" />
<PackageReference Include="Ardalis.SingleFileTestRunner.xUnitV3" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Ardalis.SingleFileTestRunner.xUnitV3&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SingleFileTestRunner
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 runon single.csfiles 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 | Versions 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.
-
net10.0
- xunit.v3.assert (>= 3.2.1)
- xunit.v3.extensibility.core (>= 3.2.1)
- xunit.v3.runner.common (>= 3.2.1)
- xunit.v3.runner.inproc.console (>= 3.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
* Add PrivateAssets none for xUnit.v3 dependencies