Writing to file in JUnit test case? Not working?
807591Mar 13 2008 — edited Mar 13 2008I have a singleton class called InstantLogger that internally uses a PrintWriter to write to file. It is very basic, has startLogger(String filename), log(String msg), and stopLogger(). startLogger just creates file, log write to file, and stopLogger closes file.
When I use this class outside of the JUnit test suite it works fine.
As soon as I use it in a JUnit test it does not write to file. It creates the file (this happens in the TestSuite), but will not write anything to it (when log is called from TestCase). I put a System.out in the log function and I see that, but still nothing writing to file. And I will say it again, it does work in non TestCase scenarios so I know it works.
Is there something that could be preventing me from writing to file in JUnit TestCase? Could this be a Singleton Issue?
Thanks,