riezebosch/hypothesist

Feature request: name a hypothesis

roycornelissen opened this issue · 1 comments

I'd like to be able to name a hypothesis and/or annotate one of the predicates with an explanation. Let's say I have two hypotheses in a unit test (yes, I'm sinning against the Unit Test Rules), then I'd like to see which of my hypotheses or predicates is failing.

Current:

Hypothesis.For<SomeMessage>()
   .Exactly(2, x => x.Name == "Manuel")
   .Any(x => x.Name == "Roy");

Requested:

Hypothesis.For<SomeMessage>("There should be two messages to Manuel and at least one to Roy")
   .Exactly(2, x => x.Name == "Manuel", because: "Manuel needs to be told twice :p")
   .Any(x => x.Name == "Roy", because: "Roy needs at least one message");

And then I'd like to see that in the output.

Several attempts to build this in I figured out it adds at least some complexity without adding much value IMHO. For focused hypothesis, I think the exception message with matched and unmatched samples is giving enough context.