pub struct FlakyRun { /* private fields */ }Expand description
Configuration for a flaky-test detection run.
§Example
use dev_flaky::FlakyRun;
let run = FlakyRun::new("my-crate", "0.1.0")
.iterations(20)
.workspace()
.allow("known_flaky::flaky_under_load")
.reliability_threshold(99.0);
let _result = run.execute().unwrap();Implementations§
Source§impl FlakyRun
impl FlakyRun
Sourcepub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
Begin a new flaky-test run. Defaults to 10 iterations.
name and version are descriptive — they identify the
subject in the produced Report.
Sourcepub fn iterations(self, n: u32) -> Self
pub fn iterations(self, n: u32) -> Self
Set how many iterations to run. Clamped to a minimum of 2 — below 2, the stable / flaky distinction is meaningless.
Sourcepub fn iteration_count(&self) -> u32
pub fn iteration_count(&self) -> u32
Configured iteration count.
Sourcepub fn in_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn in_dir(self, dir: impl Into<PathBuf>) -> Self
Run cargo test from dir instead of the current directory.
Sourcepub fn features(self, list: impl Into<String>) -> Self
pub fn features(self, list: impl Into<String>) -> Self
Pass --features <list> to every cargo test invocation.
Sourcepub fn test_filter(self, substring: impl Into<String>) -> Self
pub fn test_filter(self, substring: impl Into<String>) -> Self
Restrict every iteration to tests whose name contains the given substring (passed as the libtest positional filter argument).
Sourcepub fn allow(self, name: impl Into<String>) -> Self
pub fn allow(self, name: impl Into<String>) -> Self
Suppress a known-flaky test by name. Matches the full test path
(module::path::test_name) as emitted by libtest.
Sourcepub fn reliability_threshold(self, pct: f64) -> Self
pub fn reliability_threshold(self, pct: f64) -> Self
Classify tests with reliability below pct as flaky even
when they have zero failures across the run. The threshold is
in [0.0, 100.0].
Without this setting, a test only becomes flaky if it has at
least one failure. With reliability_threshold(99.0), tests
passing fewer than 99% of iterations are flagged even if all
iterations technically “passed” (this is a no-op as written;
it lets the classification stay strict in future revisions
that account for partial-pass criteria like sub-test runs).
Sourcepub fn subject_version(&self) -> &str
pub fn subject_version(&self) -> &str
Subject version passed in via new.
Sourcepub fn execute(&self) -> Result<FlakyResult, FlakyError>
pub fn execute(&self) -> Result<FlakyResult, FlakyError>
Execute the run.
Invokes cargo test --no-fail-fast N times and accumulates
per-test pass / fail / ignored counters. Subprocess failures
(no cargo on PATH, etc.) surface as
FlakyError::SubprocessFailed. Per-iteration test failures
are the point of the run — they don’t error out the
FlakyRun.