Meziantou.Xunit
2.0.4
Prefix Reserved
See the version list below for details.
dotnet add package Meziantou.Xunit --version 2.0.4
NuGet\Install-Package Meziantou.Xunit -Version 2.0.4
<PackageReference Include="Meziantou.Xunit" Version="2.0.4" />
<PackageVersion Include="Meziantou.Xunit" Version="2.0.4" />
<PackageReference Include="Meziantou.Xunit" />
paket add Meziantou.Xunit --version 2.0.4
#r "nuget: Meziantou.Xunit, 2.0.4"
#:package Meziantou.Xunit@2.0.4
#addin nuget:?package=Meziantou.Xunit&version=2.0.4
#tool nuget:?package=Meziantou.Xunit&version=2.0.4
Meziantou.Xunit
Meziantou.Xunit provides xUnit.v3 attributes to run or skip tests depending on the current environment.
Installation
dotnet add package Meziantou.Xunit
Usage
using Meziantou.Xunit;
using Xunit;
namespace MyProject.Tests;
public sealed class SampleTests
{
[Fact]
[RunIf(TestOperatingSystems.Windows | TestOperatingSystems.Linux)]
public void Runs_on_windows_or_linux()
{
}
[Fact]
[RunIf(globalizationMode: TestGlobalizationMode.NotInvariant)]
public void Runs_only_when_invariant_globalization_is_disabled()
{
}
[Fact]
[SkipIf(WindowsGroups.Administrator)]
public void Skipped_when_running_as_administrator()
{
}
[Fact]
[RunIf(ContinuousIntegration = ContinuousIntegrationEnvironments.GitHubActions)]
public void Runs_only_on_github_actions()
{
}
}
RunIf executes the test only when all specified conditions match. SkipIf skips the test when all specified conditions match.
Both attributes can be applied to a test method and to its test class, but only once per target. An attribute that specifies no condition has no effect.
Conditions are evaluated once the test class instance has been created. Class fixtures, the test class constructor and IAsyncLifetime.InitializeAsync therefore run even when the test ends up being skipped.
Supported conditions
| Condition | Type | Values |
|---|---|---|
OperatingSystem |
TestOperatingSystems |
Windows, Linux, MacOS (Flags) |
GlobalizationMode |
TestGlobalizationMode |
Any, Invariant, NotInvariant |
ContinuousIntegration |
ContinuousIntegrationEnvironments |
GitHubActions |
WindowsGroup |
WindowsGroups |
Any, User, Administrator |
GlobalizationMode reflects invariant globalization mode, which is enabled by the InvariantGlobalization MSBuild property or the DOTNET_SYSTEM_GLOBALIZATION_INVARIANT environment variable. Invariant means culture data is not available; NotInvariant means it is.
WindowsGroups.User means the current user is a member of the built-in Users group and is not elevated as an administrator. Any value other than Any also requires Windows.
| 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. net11.0 is compatible. |
-
net10.0
- xunit.v3.extensibility.core (>= 4.0.1)
-
net11.0
- xunit.v3.extensibility.core (>= 4.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.