matcher-combinators icon indicating copy to clipboard operation
matcher-combinators copied to clipboard

Failure reporting not compatible with Cursive

Open dryewo opened this issue 7 years ago • 4 comments

Cursive's test runner is quite convenient, it supports clojure.test. One can run a failing test by setting the caret in the middle of it and Tools > REPL > Run 'test-1' in REPL and get this output:

(deftest test-1
  (is (= [1 3] [1 2])))
Loading test/foo_1/core_test.clj... done
Running foo-1.core-test/test-1
Ran 1 test containing 1 assertion.
1 failure, 0 errors.

There is a visual effect of it:

image

One can even open a side-to-side diff by clicking on the exclamation icon.

If we use match? instead, it does not work:

(deftest test-2
  (is (match? [1 odd?] [1 2])))
Loading test/foo_1/core_test.clj... done
Running foo-1.core-test/test-2
], :expected "(match? [1 odd?] [1 2])", :actual "(not (matcher-combinators.test/match? [1 #object[clojure.core$odd_QMARK_ 0x404f8ad4 \"clojure.core$odd_QMARK_@404f8ad4\"]] [1 2]))", :message nil, :file "core_test.clj", :line 18}Ran 1 test containing 0 assertions.
No failures.

The output looks broken, and the summary says "No Failures".

If we use clojure.test/run-all-tests, it works:

(run-all-tests #"foo-1.core-test")

Testing foo-1.core-test

FAIL in (test-1) (core_test.clj:7)
expected: (= [1 3] [1 2])
  actual: (not (= [1 3] [1 2]))

FAIL in (test-2) (core_test.clj:18)
mismatch:
[1 (predicate "clojure.core$odd_QMARK_@404f8ad4" 2)]

Ran 2 tests containing 2 assertions.
2 failures, 0 errors.
=> {:test 2, :pass 0, :fail 2, :error 0, :type :summary}

It probably has something to do with "mismatch:" used instead of "expected:" and "actual:" in the reporting. I wonder, can it be nicely adapted so that it works naturally with both lein test and with Cursive?

dryewo avatar Apr 07 '18 10:04 dryewo

Hey @dryewo thanks for reporting!

We had a similar issue with cider's test runner (https://github.com/clojure-emacs/cider/issues/2215). I imagine the solution to these issues will be more or less similar.

Hope to get some time to dive into this in two or so weeks; currently focused on preparing a talk..

philomates avatar Apr 10 '18 09:04 philomates

@cursive-ide Any docs, source code, or tips on how I could integrate cursive with matcher-combinators? I'm not a user but many at my company are and so it would be very useful to fix this, and I would be happy to contribute in any way possible.

I can see that some people have already inquired about this here https://github.com/cursive-ide/cursive/issues/875

philomates avatar Jun 14 '19 11:06 philomates

This is a frequent problem for me. I often have very large data structures on the RHS of my match? assertions. When the assertion fails I'm stuck either switching to an = assertion to get the nice Cursive test failure window, or I have to manually skim the test output for mismatch buried somewhere in the test failure report. This test failure report is only visible in a tooltip when I hover over the test failure, and I can't easily copy the text from the tooltip.

bgrabow avatar Jun 24 '22 18:06 bgrabow

I'm planning support for this in the next EAP release.

cursive-ghost avatar Jun 24 '22 22:06 cursive-ghost

Any updates on this @cursive-ide ? I think I'm going to close it here given that there is nothing matcher-combinators can do to address this; at least as far as I know, happy to help if that isn't hte case

philomates avatar Feb 08 '23 16:02 philomates