testing println in clojure.test

369 views
Skip to first unread message

Kevin Kleinfelter

unread,
May 30, 2017, 5:43:17 PM5/30/17
to Clojure
I've got a function which is supposed to println a computed value.  How do I test whether it printed that value, when using clojure.test?

Or, another way of asking the same question is how do I grab the output from println when testing a function with clojure.test?

TIA

Andy Fingerhut

unread,
May 30, 2017, 6:00:44 PM5/30/17
to clo...@googlegroups.com
The with-out-str macro should be able to do this for you.  A few examples of use can be found on ClojureDocs here:


You may find the Clojure cheat sheet useful for discovering things like this (at least for things the cheat sheet includes -- it doesn't cover any but a tiny handful of functions outside of Clojure core functionality).  In particular for your question, the section titled "IO" (i.e. Input/Output), subsection "to string" would have helped:


Andy

--
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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages