marick / Midje

Midje provides a migration path from clojure.test to a more flexible, readable, abstract, and gracious style of testing
MIT License
1.68k stars 128 forks source link

No detailed error message using `has every?` #298

Open matthewgertner opened 9 years ago

matthewgertner commented 9 years ago

I'd like to test a sequence of maps against a schema I've defined using Prismatic schema. I get nice detailed error output from vice if I say something like:

my-object => (matches MySchema)

However, if I test the whole sequence like this:

my-objects => (has every? (matches MySchema))

it tells me when it fails but doesn't say why. All I see is that such-and-such a value did not match (has every (matches MySchema)) not that some required property is missing or has the wrong type or whatever.

Am I doing something wrong? Is this a Midje bug? Or is it by design?

matthewgertner commented 9 years ago

To clarify, when I say:

(first my-objects) => (matches MySchema)

I get output like:

The checker said this about the reason:
    {:project (not (instance? java.lang.Integer "dakrone/clj-http"))}

So I can see exact what went wrong (i.e. :project is not an integer although that is what the schema specifies). When I say:

my-objects => (has every? (matches MySchema))

I see:

Actual result did not agree with the checking function.
    Actual result: ...
Checking function: (has every? (matches MySchema))

So I can see there is a problem, but I have no indication of which items did not match the schema and which fields didn't match.

marick commented 9 years ago

Since the matches checkers return "data-laden-falsehoods", has has the information to print those messages. Added to trello https://trello.com/c/6p1GLdxg/5-has-etc-should-take-advantage-of-data-laden-falsehoods