use std::path::{Path, PathBuf};
use std::process::Command;
use test_better::prelude::*;
fn fixture_dir(name: &str) -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("fixtures")
.join(name)
}
#[test]
fn groups_failures_by_feature_area_and_keeps_unstructured_ones() -> TestResult {
let dir = fixture_dir("structured-failures");
let output = Command::new(env!("CARGO_BIN_EXE_cargo-test-better"))
.current_dir(&dir)
.output()
.or_fail_with("spawn the cargo-test-better binary")?;
let stdout = String::from_utf8(output.stdout).or_fail_with("runner stdout is utf-8")?;
check!(output.status.success()).satisfies(is_false())?;
let report = stdout
.split_once("test-better: grouped failures")
.or_fail_with("the runner printed its grouped report")?
.1;
check!(report.contains("the user store")).satisfies(is_true())?;
check!(report.contains("the http layer")).satisfies(is_true())?;
check!(report.matches("the user store").count()).satisfies(eq(1))?;
check!(report.contains("user_count_matches")).satisfies(is_true())?;
check!(report.contains("user_store_connects")).satisfies(is_true())?;
check!(report.contains("unstructured (no test-better failure data)")).satisfies(is_true())?;
check!(report.contains("arithmetic_is_hard")).satisfies(is_true())
}