FlakyTest.XUnit
2.3.13
See the version list below for details.
dotnet add package FlakyTest.XUnit --version 2.3.13
NuGet\Install-Package FlakyTest.XUnit -Version 2.3.13
<PackageReference Include="FlakyTest.XUnit" Version="2.3.13" />
paket add FlakyTest.XUnit --version 2.3.13
#r "nuget: FlakyTest.XUnit, 2.3.13"
// Install FlakyTest.XUnit as a Cake Addin #addin nuget:?package=FlakyTest.XUnit&version=2.3.13 // Install FlakyTest.XUnit as a Cake Tool #tool nuget:?package=FlakyTest.XUnit&version=2.3.13
FlakyTest.XUnit
Overview
Do you have some flaky tests? Are you using XUnit? Do you want to retry your flaky tests a few times before considering them failures? Heck yeah brother! (You should probably actually fix the test so it's not flaky, but sometimes you just don't have time!)
If you still want an easy way to mark a test or two (but no more than that!) as flaky, then this might be the package for you.
Usage
FlakyFact
/ FlakyTheory
It probably can't get much easier to consume this functionality. If you're already used to decorating your test methods with [Fact]
you're almost there!
Example
using FlakyTest.XUnit.Attributes;
[FlakyFact("this test is heckin flaky my dude, follow up to fix this in JIRA-1234", 42)]
public async Task WhenDoingThing_ShouldHaveThisResult()
{
// your test implementation which is sometimes flaky
}
[FlakyTheory("same idea as flaky fact, just using a theory. follow up to fix this in JIRA-1234", 42)]
[InlineData(true)]
[InlineData(false)]
public async Task WhenDoingThing_ShouldHaveThisResult(bool isDoots)
{
// your test implementation which is sometimes flaky
}
The project requires the first string parameter flakyExplanation
to be not null/empty... cuz you really shouldn't be using this anyway. This can be used as a way to describe how/why the test is flaky, and perhaps leave a note and ticket for follow up to get the flakyness aspect of the test fixed.
The second parameter indicates how many times the test can "fail" before the test runner actually reports it as failure. The default value here (at the time of writing this) is 5 - meaning the test can fail 5 times prior to the runner reporting it as a failure. If the test passes on the first, fourth, or any test in between, it is immediately marked as successful to the runner.
MaybeFixedFact
/ MaybeFixedTheory
Did you have a test your were previously decorating as Flaky
? Have you made updates to the code or test and want to check that it's no longer flaky? Well the attributes MaybeFixedFact
and MaybeFixedTheory
may be for you!
Use these attributes to signal to the test runner that the tests decorated as such should be run x
times to consider them "successful".
If x
is 10, the test will be run up to 10x. The runner will bail early if a failure is encountered up to x
, once x
is arrived at with all passing tests, the test is considered an overall disposition of "passed". This x
value is configurable, but is 10 by default (at the time of writing this documentation anyway).
Example
using FlakyTest.XUnit.Attributes;
[MaybeFixedFact(42)]
public async Task WhenDoingThing_ShouldHaveThisResult()
{
// your test implementation which was sometimes flaky
// checking now that it's no longer flaky by running
// the test 42 times before (and they must all be individually passing) being considered a passed test
}
[FlakyTheory]
[InlineData(true)]
[InlineData(false)]
public async Task WhenDoingThing_ShouldHaveThisResult(bool isDoots)
{
// your test implementation which was sometimes flaky
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- xunit.core (>= 2.4.0)
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 |
---|---|---|
2.4.10 | 58,026 | 1/30/2023 |
2.3.13 | 43,035 | 1/25/2023 |
2.2.5 | 301 | 1/23/2023 |
2.1.5 | 310 | 1/21/2023 |
2.0.4 | 306 | 1/15/2023 |
1.0.5 | 381 | 1/8/2023 |
1.0.4-prerelease | 149 | 1/8/2023 |
1.0.1-prerelease | 149 | 1/8/2023 |