XFEExtension.NetCore.XUnit 4.0.2

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

XFEExtension.NetCore.XUnit 4.0

An independent .NET 10 test and statistical benchmark runner. Despite the historical package name, this project is not based on or affiliated with xUnit.net.

Tests

[TestFixture]
public class CalculatorTests
{
    [BeforeEach]
    public void SetUp() { }

    [TestCase(1, 2, 3)]
    [TestCase(2, 3, 5)]
    public void Adds(int left, int right, int expected)
        => Assert.Equal(expected, left + right);

    [Test]
    public async Task CompletesAsync()
        => await Task.Delay(1);
}

The incremental source generator discovers tests at build time, emits strongly typed invokers, and generates an entry point when the project does not already have one. async void tests are rejected because no runner can await their completion reliably.

Run tests directly:

dotnet run -c Release
dotnet run -c Release -- --filter Calculator --category Unit

Different classes run in parallel by default while methods in one class remain serial. Use [Collection], [NonParallel], [Timeout], and [Isolated] for shared resources and process isolation. Results are exported as console output, JSON, and JUnit XML.

The console automatically selects Simplified Chinese when the current UI culture is Chinese and otherwise falls back to English. Override it at any time with --language en, --language zh, or --language auto. The adaptive interface includes a two-column run card, encoding-safe status badges, aligned test durations, hierarchical failure details, success-rate and slow-test summaries, benchmark environment information, convergence warnings, and a detailed benchmark table. Redirected output remains plain text and honors NO_COLOR.

Benchmarks

public class ParserBenchmarks
{
    [Params(10, 100)]
    public int Count { get; set; }

    [Benchmark(Baseline = true)]
    public int Baseline() => Enumerable.Range(0, Count).Sum();

    [Benchmark]
    public int Candidate() => Enumerable.Range(0, Count).Aggregate(0, (sum, value) => sum + value);
}

Benchmarks are opt-in and must be run from an optimized Release build:

dotnet run -c Release -- --benchmarks
dotnet run -c Release -- --benchmarks --quick

The balanced job pilots invocation count, targets approximately 500 ms iterations, performs 6–50 warmups and 15–100 measurements, calibrates a return-shape-compatible empty workload, and stops at an approximately 2% relative error target using a 99.9% confidence interval. Raw samples, outliers, allocation, and GC counts are retained in JSON; Markdown and CSV summaries are also produced. Results below measurable infrastructure overhead are reported as such rather than presented as precise single-operation timings.

Performance gating is explicit:

dotnet run -c Release -- --benchmarks --baseline previous/benchmark-results.json --max-regression 0.05

Configuration

Project defaults may be stored in xfe.runsettings.json. Precedence is CLI, method/class/assembly attributes, configuration file, then built-in defaults.

{
  "language": "Auto",
  "tests": { "parallel": true, "maxParallelism": 8 },
  "benchmark": { "targetIterationMilliseconds": 500, "maxRelativeError": 0.02 },
  "reports": { "artifactsPath": "XfeTestArtifacts" }
}

Useful commands include --tests, --benchmarks, --all, --list, --filter, --category, --parallel, --no-parallel, --fail-fast, --explicit, --language, --artifacts, --baseline, --max-regression, and --help.

Extensions

Register one or more assembly-level [UseExtension(typeof(...))] attributes to add an ITestReporter, IBenchmarkExporter, or a single ITestActivator. A [MemberData] member may return either an enumerable of rows or an ITestCaseDataSource. The activator owns test/fixture creation and asynchronous disposal for the run.

The analyzer rejects async void and invalid lifecycle signatures. Migration diagnostics for the 3.x attributes include code fixes; the code-fix assembly is kept separate from the command-line analyzer/generator so Release builds do not acquire a Roslyn Workspaces dependency.

Migrating from 3.x

CTest, MTest, MRTest, SMTest, SetUp, and XFECode remain source-compatible for the 4.x line and are marked obsolete. Migrate to TestFixture, Test, TestCase, Benchmark, BeforeEach, and Assert. SMTest, SMNTest, SMRTest, and SMNRTest keep their original single-run behavior: they run in the default test mode without command-line options, await asynchronous results, compare legacy expected return values, and show all captured console output in a dedicated compatibility panel. Modern Benchmark methods remain opt-in through --benchmarks. The compatibility surface will be removed in 5.0.

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.
  • net10.0

    • No dependencies.

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
4.0.2 76 8/17/2026
4.0.1 75 8/17/2026
4.0.0 75 8/14/2026
3.0.0 125 5/10/2026
2.1.1 141 3/25/2026
2.1.0 110 3/25/2026
2.0.5 169 1/24/2026
2.0.4 371 8/18/2024
2.0.3 299 4/16/2024
2.0.2 219 4/14/2024
2.0.1 254 3/20/2024
2.0.0 243 3/7/2024

4.0.1 恢复 SMTest 的默认单次执行、完整控制台输出和兼容界面;现代 Benchmark 行为保持不变。