Pretty-printing `lein test`s output?

828 views
Skip to first unread message

vemv

unread,
Feb 14, 2013, 6:06:51 PM2/14/13
to clo...@googlegroups.com
First of all, I must say I'm new to testing in Clojure. My current workflow is pretty simple:

* Edit + save the tests (which use clojure.test - I hear Midje is better though) in emacs
* Run `lein test` in the terminal
* recur

But then the printed values (triggered when e.g. an `are` case fails) are fairly illegible, especially when big.

Can I get the test runner to pprint its output? Is my workflow improvable anyway?

Thanks - Victor

Alex Baranosky

unread,
Feb 14, 2013, 9:56:41 PM2/14/13
to clo...@googlegroups.com
Hi Victor, 

I've developed something I use on my own projects to compare pretty printed test failure output. The final piece for it would be to incorporate its test failure report diffing into a leiningen plugin that wrapped lein test. 


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Phil Hagelberg

unread,
Feb 15, 2013, 12:19:59 AM2/15/13
to clo...@googlegroups.com
On Thu, Feb 14, 2013 at 3:06 PM, vemv <ve...@vemv.net> wrote:
> But then the printed values (triggered when e.g. an `are` case fails) are
> fairly illegible, especially when big.
>
> Can I get the test runner to pprint its output? Is my workflow improvable
> anyway?

I use lein-difftest for this: https://github.com/brentonashworth/lein-difftest

-Phil

Sean Corfield

unread,
Feb 15, 2013, 1:11:23 AM2/15/13
to clo...@googlegroups.com
You'll find your workflow greatly improved by using nrepl (or
slime/swank) and running tests directly from Emacs - and that applies
whether you're using bare clojure.test, midje or expectations.

I use expectations for testing and expectations-mode in Emacs. I can
run an individual namespace's tests with C-c , and it shows the pass /
fail summary in the minibuffer and highlights any failing tests in
orange or red (depending on how they failed). It also shows the
pass/fail summary in the repl buffer. Pretty sure there are equivalent
modes for both clojure.test and midje.

On Thu, Feb 14, 2013 at 3:06 PM, vemv <ve...@vemv.net> wrote:
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Víctor M. V.

unread,
Feb 15, 2013, 4:00:10 AM2/15/13
to clo...@googlegroups.com
I just tried out both lein-difftest and gui-diff and they work just great. I'd love a `lein test` command that defaulted to the former and could resort to the latter when things got hairy. But that's just wishful thinking at the moment :)

Thanks you Sean for the advice as well - the workflow you describe sounds damn good. Now I'm not sure if I want lein or emacs to drive my tests. Perhaps a best-of-both-worlds approach is possible.

Hugo Duncan

unread,
Feb 15, 2013, 8:46:34 AM2/15/13
to clo...@googlegroups.com
Sean Corfield <seanco...@gmail.com> writes:

> You'll find your workflow greatly improved by using nrepl (or
> slime/swank) and running tests directly from Emacs - and that applies
> whether you're using bare clojure.test, midje or expectations.

For nrepl.el, via clojure-test-mode, There is an pull request [1] to add
inspection of test failures using pretty printing. The pull request
also adds inspection of test failures using ediff to compare actual and
expected.

[1] https://github.com/technomancy/clojure-mode/pull/139
Reply all
Reply to author
Forward
0 new messages