utfallsrum for idiots
utfallsrum = a function's "outcome space" = all the kinds of answer it can give.
The one idea
Don't test ONE answer. List ALL the kinds of answer, then test ONE of EACH kind. utfallsrum gives you a score: how many kinds did you cover?
A function like clamp01(x) gives three KINDS of answer:
- you gave it a too-small number → it returns
0.0 - you gave it a normal number → it returns the number
- you gave it a too-big number → it returns
1.0
That's 3 classes. Test one of each → score 3/3 = 1.0 = done. Test only the middle one → score 1/3 = 0.33. Green, but not done — you only checked one kind of answer.
Type it out
use nornir_testmatrix::utfallsrum::Outcome;
// 1. List the kinds (with what "correct" means for each)
let mut o = Outcome::for_fn("clamp01")
.class("too-small", "below 0 ⇒ returns 0.0")
.class("normal", "0..1 ⇒ returns the number")
.class("too-big", "above 1 ⇒ returns 1.0");
// 2. Check one of each, and tell utfallsrum you did (with the real answer)
assert_eq!(clamp01(-2.0), 0.0); o.hit("too-small", "clamp01(-2.0) == 0.0");
assert_eq!(clamp01(0.5), 0.5); o.hit("normal", "clamp01(0.5) == 0.5");
assert_eq!(clamp01(9.0), 1.0); o.hit("too-big", "clamp01(9.0) == 1.0");
// 3. Ask for the score
assert_eq!(o.covered(), 1.0); // covered all 3 kinds → done
If you only hit one of them, o.covered() is 0.33 and o.unexercised() tells you exactly which kinds you forgot.
Where the score goes
#[cfg(feature = "testmatrix")]
o.emit("my-thing"); // shows up in `nornir test` as rows + a score
A green roll-up means you covered the whole outcome space. A red one means you skipped a kind — and it tells you which one.
Why the gate cares
The completeness gate won't mark a button/tab/command "covered" just because ONE test touched it. It wants you to have covered at least 2 kinds of its answer (empty / one / many, say). One value isn't enough — that's the whole point.
In one sentence
List the kinds of answer, test one of each, and utfallsrum scores how many kinds you covered — one value is never the whole space.
More detail: testmatrix-utfallsrum-guide.md.