Test simulating a stdin

My -main function reads arguments from *in*, like this:

(defn -main
  [& args]
  (doseq [ln (line-seq (java.io.BufferedReader. *in*))]
  ; Do something...
))

I use my app basically like: $ lein run < input.txt.

I would like to test this function but I don’t know how I would write a test case that simulates the stdin passing data to my -main function.

Is this the right approach to test this situation?

Thank you.

Would with-in-str solve your issue? https://clojuredocs.org/clojure.core/with-in-str

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.