Re: How to capture printing in a unit test

2009-02-04 Thread samppi
Awesome. Thanks for the answers, everyone. On Feb 4, 3:07 pm, Meikel Brandmeyer wrote: > Hi, > > Am 04.02.2009 um 23:01 schrieb Laurent PETIT: > > > this should work for you : > > >    (binding [*out* (java.io.StringWriter.)] > >       (printing-fn) > >       (= (.toString *out*) "YES")) > > The

Re: How to capture printing in a unit test

2009-02-04 Thread Meikel Brandmeyer
Hi, Am 04.02.2009 um 23:01 schrieb Laurent PETIT: this should work for you : (binding [*out* (java.io.StringWriter.)] (printing-fn) (= (.toString *out*) "YES")) There is also with-out-str: (= "YES" (with-out-str (printing-fn))) (And for the record: there is also a with-in-st

Re: How to capture printing in a unit test

2009-02-04 Thread Laurent PETIT
Hello, this should work for you : (binding [*out* (java.io.StringWriter.)] (printing-fn) (= (.toString *out*) "YES")) Regards, -- Laurent 2009/2/4 samppi > > I want to test if a certain function prints a certain message to the > system's standard output. How may I go about do

How to capture printing in a unit test

2009-02-04 Thread samppi
I want to test if a certain function prints a certain message to the system's standard output. How may I go about doing this? (defn printing-fn [] (print "YES")) (deftest test-printing-fn (some-context-that-switches-the-default-target-of-printing (printing-fn) (is (= the-standard-out