Re: DISCUSS: tests that read and write files

2009-04-09 Thread Daniel Jomphe
Stuart Halloway wrote: > concerns: > (1) Would like to see the file after a failed test. > (2) [...] I would be much more   > comfortable not having to rely on code to write the file first.   > Doesn't feel like a unit test. > > But I am much more interested in having a shared approach that all  

Re: DISCUSS: tests that read and write files

2009-04-09 Thread Victor Rodriguez
On Thu, Apr 9, 2009 at 3:57 PM, Stuart Halloway wrote: > > Three concerns: > > (1) Would like to see the file after a failed test. Unit tests should write their files to the temp directory (using the system property java.io.tmpdir). This way, unit tests do not pollute your project directory, an

Re: DISCUSS: tests that read and write files

2009-04-09 Thread Stuart Halloway
Three concerns: (1) Would like to see the file after a failed test. (2) Also have tests that read a file, and I would be much more comfortable not having to rely on code to write the file first. Doesn't feel like a unit test. (3) The macro is more complex than the code being tested. :-) (Th

Re: DISCUSS: tests that read and write files

2009-04-09 Thread Stuart Sierra
My recommendation would be to use a temporary file that is created and deleted in a macro or fixture. (defmacro with-tmp-properties-file [& body] `(binding [*tmp-properties-file* (File/createTempFile "temp" ".properties")] (spit *tmp-properties-file* "contents of the test file") ~...@

DISCUSS: tests that read and write files

2009-04-09 Thread Stuart Halloway
In r659 I added a unit test to clojure-contrib that needed to read and write from the filesystem. I picked a dumb and simple convention, and welcome review from other committers to move to something that is just- smart-enough. Stu --~--~-~--~~~---~--~~ You re