XUnit3Helper 0.0.5-alpha
This is a prerelease version of XUnit3Helper.
dotnet add package XUnit3Helper --version 0.0.5-alpha
NuGet\Install-Package XUnit3Helper -Version 0.0.5-alpha
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="XUnit3Helper" Version="0.0.5-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XUnit3Helper" Version="0.0.5-alpha" />
<PackageReference Include="XUnit3Helper" />
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 XUnit3Helper --version 0.0.5-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XUnit3Helper, 0.0.5-alpha"
#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 XUnit3Helper@0.0.5-alpha
#: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=XUnit3Helper&version=0.0.5-alpha&prerelease
#tool nuget:?package=XUnit3Helper&version=0.0.5-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XUnit3Helper
A utility library for convenient work with xUnit v3.
Designed to speed up writing parameterized tests and to simplify preparing mocks in DI containers.
Key features
- Attribute
JsonFileDataAttribute— load data forTheoryfrom a JSON file (multiple formats, sections). - Attribute
CustomAutoDataAttribute— ready-made configuration forAutoFixture+AutoMoq(includingConfigureMembersand recursion behavior). - Extension
MockExtension.AddMocks— bulk registration ofMoqmocks intoIServiceCollection. - Helper generator
GenerateTestDataExtensionand modelTestData— support for deserializing JSON into parameter sets up to 15 arguments. - Supported targets:
net8.0,net9.0,net10.0.
Usage
JsonFileDataAttribute
- Constructor:
JsonFileDataAttribute(string filePath, bool simpleTypeJson = false, string? sectionKey = null) - Behavior:
- Checks that the file exists.
- If
sectionKeyis specified, extracts the corresponding JSON section (top-level key). - Supports two JSON formats:
- "Complex" — an array of objects with fields
P1,P2, ... (matches theTestDatamodels). - "Simple" (
simpleTypeJson = true) — an array of arrays or an array of strings/numbers, where each element of an inner array corresponds to a test parameter.
- "Complex" — an array of objects with fields
- Limitation: up to 15 parameters (the test-case generation logic is implemented for 1..15 parameters).
- Examples: Complex data format (recommended):
[
{
"P1": 1,
"P2": "a",
"P3": true
},
{
"P1": 2,
"P2": "b",
"P3": false
}
]
Simple types format (simpleTypeJson = true):
[
[1, "a", true],
[2, "b", false]
]
Usage in tests:
[Theory, JsonFileData("testdata.json")]
public void MyTest(int a, string b, bool flag)
{
// ...
}
[Theory, JsonFileData("simple.json", simpleTypeJson: true)]
public void SimpleTest(int a, string b)
{
// ...
}
[Theory, JsonFileData("config.json", sectionKey: "cases")]
public void SectionedTest(int x, int y)
{
// ...
}
CustomAutoDataAttribute
- A simplified attribute for use with
AutoFixture+AutoMoq. - Configuration:
- Adds
AutoMoqCustomizationwithConfigureMembers = true. - Removes
ThrowingRecursionBehaviorand addsOmitOnRecursionBehaviorto safely generate object graphs.
- Adds
- Example:
[Theory, CustomAutoData]
public void AutoFixtureTest(MyService sut, int n)
{
Assert.NotNull(sut);
}
MockExtension.AddMocks
- An extension for
IServiceCollection: for each providedTypeit registers:Mock<T>as scoped,T(mock.Object) as scoped.
- Removes existing registrations for the type before adding the mock.
- Example:
var services = new ServiceCollection();
services.AddMocks(typeof(IMyService), typeof(IOtherService));
or with generics (implemented via reflection for each type in the code).
License
- MIT
| Product | Versions 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 is compatible. 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 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
- AutoFixture.AutoMoq (>= 5.0.0-preview0012)
- AutoFixture.Xunit3 (>= 5.0.0-preview0012)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- xunit.v3.extensibility.core (>= 3.2.0)
-
net8.0
- AutoFixture.AutoMoq (>= 5.0.0-preview0012)
- AutoFixture.Xunit3 (>= 5.0.0-preview0012)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- xunit.v3.extensibility.core (>= 3.2.0)
-
net9.0
- AutoFixture.AutoMoq (>= 5.0.0-preview0012)
- AutoFixture.Xunit3 (>= 5.0.0-preview0012)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- xunit.v3.extensibility.core (>= 3.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XUnit3Helper:
| Package | Downloads |
|---|---|
|
XUnit3Helper.Integration
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.5-alpha | 269 | 11/13/2025 |
| 0.0.4-alpha | 100 | 11/8/2025 |
| 0.0.3-alpha | 141 | 10/30/2025 |