test.check

Add ability to customize test output when a test fails

Details

  • Type: Enhancement Enhancement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

From the original description:

I would like the ability to control / enhance / replace the output generated when a test fails. Printing the raw values works well as long as those values have a useful output for the test at hand, but this doesn't always hold true.

To give a bit of background, I was playing with generating sequences of partially-applied functions and then applying them to an initial state. Here's a small excerpt from the full gist:

:smallest [(#<core$partial$fn__4190 clojure.core$partial$fn__4190@2a799171>)]

What would be more useful to me is if the output had something like this, which is more meaningful:

:smallest [(- 45 %)]

In this example, (- 45 %) is all my custom output string. 45 is a value from an upstream generator (and would thus change), and % is just a string modeled after the anonymous function syntax.

I could even see my particular application rolled up as a generator:

(def gen-inc
  (gen/bind gen/pos-int #(gen/partial + %)))

Which could handle some of the heavy lifting for the user.

Original issue

Activity

Hide
Gary Fredericks added a comment - - edited

I'm going to say this has been completed as much as I'm interested in doing it.

For clojure.test.check/quick-check, I think this is a non-issue, since the user has the interested data returned and can do whatever they want with it, including transforming it for readability.

For clojure.test.check.clojure-test/defspec, there is now (on master) the ability to customize printing via the :reporter-fn option, so this should be sufficient for other transformations.

Show
Gary Fredericks added a comment - - edited I'm going to say this has been completed as much as I'm interested in doing it. For clojure.test.check/quick-check, I think this is a non-issue, since the user has the interested data returned and can do whatever they want with it, including transforming it for readability. For clojure.test.check.clojure-test/defspec, there is now (on master) the ability to customize printing via the :reporter-fn option, so this should be sufficient for other transformations.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: