Skip to main content
Xunit.DependencyInjection package icon

Xunit.DependencyInjection

Use Microsoft.Extensions.DependencyInjection to inject xunit testclass. If you want write Microsoft.Extensions.Logging to ITestOutputHelper, please install Xunit.DependencyInjection.Logging Release notes: 8.8: Added support `BuildHost` method in startup. 8.7: Allow missing default startup in some case. 8.6: Support any awaitable type of async test method. 8.5: Change analyzer category. 8.4: Fix #63: allow modify default service from DI container. 8.3: Add ActivitySource(name: Xunit.DependencyInjection) and ValueTask/ValueTask<> support. 8.2: Fix #60: support IAsyncDisposable. 8.1: Startup allow static method or class (like Asp.Net Core startup). 8.0: New feature: Support multiple startup. 7.7: Add [MethodData], like [MemberData], support injection. 7.6: Fix #48, each TestRunner should have a different scope. 7.5: Add XunitTestCaseRunnerAdapter, It will be support more XunitTestCase type. 7.4: Always set applicationName, unwarp TargetInvocationException. 7.3: Fix #41, activate ITestOutputHelperAccessor on tests without a constructor. 7.2: Add Startup analyzer. 7.1: Fix can't run test case when host.StartAsync() throw exception. 7.0: Add fixture injection and refactor DependencyInjectionTestFramework, you don't have to declare the [assembly: TestFrameworkAttribute] on normal case.

Total Downloads
22.3M
22,324,896
Published
Aug 22, 2023
Latest stable version

Install

.NET CLI
dotnet add package Xunit.DependencyInjection --version 8.8.1
Package Manager Console
Install-Package Xunit.DependencyInjection -Version 8.8.1
PackageReference
<PackageReference Include="Xunit.DependencyInjection" Version="8.8.1" />

Frameworks

.NETFramework4.6.1 .NETStandard2.0

Dependencies

[6.0.0, )
[6.0.0, )
[2.4.2, 3.0.0)
[6.0.0, )
[6.0.0, )
[2.4.2, 3.0.0)

Adoption guide

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

How to read this guidance

Sources: published NuGet v3 registry metadata and explicit NuBrowse editorial guides. Refresh: package metadata is refreshed from NuGet when the page loads. Limit: this is not a security, legal or compatibility guarantee; validate the selected version in your project.

Useful next steps

Move from package metadata to a concrete selection or review workflow.