Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show test.check's generated input for failing tests #1825

Closed
sebastianpoeplau opened this issue Aug 18, 2016 · 2 comments
Closed

Show test.check's generated input for failing tests #1825

sebastianpoeplau opened this issue Aug 18, 2016 · 2 comments

Comments

@sebastianpoeplau
Copy link
Contributor

CIDER nicely displays the expected and actual outcome for tests in the clojure.test framework. However, when the tests are based on test.check the output lacks information about the generated inputs.

For example, consider the following property:

(defspec whatever
  (prop/for-all [x gen/int]
    (= 0 x)))

Checking it in CIDER yields this output:

Fail in whatever
expected: result
  actual: false

It would be nice to also learn which x caused the test to fail. To this end, I would suggest to capture that very piece of information from the test.check results and display it in the result buffer whenever applicable.

Technically, the information about the failing input has to be propagated to cider-nrepl.middleware.test/report, where it could be stored and passed to the Emacs plugin for display. Unfortunately, clojure.test.check.clojure-test.defspec doesn't do so yet, throwing away everything except the success status, but the extension should be relatively simple. The utility library test.chuck already demonstrates a way to go: it calls the report function, in our case cider-nrepl.middleware.test/report, with an event of :type ::shrunk when it has worked out the smallest failing inputs. As a first step, one might extend cider-nrepl.middleware.test/report to handle events of that type and have CIDER display the information in the result buffer. Then the same concept could be applied to test.check's defspec. I'll play around with it...

@jeffvalk
Copy link
Contributor

Definitely. This was always on my radar for cider-test, but clearly I hadn't gotten to that blip. :)

sebastianpoeplau added a commit to sebastianpoeplau/cider-nrepl that referenced this issue Aug 20, 2016
We now capture test input as generated by `test.check` and pass it on to
cider_test.el for display.
sebastianpoeplau added a commit to sebastianpoeplau/cider that referenced this issue Aug 20, 2016
sebastianpoeplau added a commit to sebastianpoeplau/cider that referenced this issue Aug 20, 2016
bbatsov pushed a commit to clojure-emacs/cider-nrepl that referenced this issue Aug 20, 2016
We now capture test input as generated by `test.check` and pass it on to
cider_test.el for display.
@sebastianpoeplau
Copy link
Contributor Author

I've created a ticket for test.check to forward shrunk inputs as well: http://dev.clojure.org/jira/browse/TCHECK-118.

sebastianpoeplau added a commit to sebastianpoeplau/cider-nrepl that referenced this issue Sep 4, 2016
bbatsov pushed a commit to clojure-emacs/cider-nrepl that referenced this issue Sep 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants