I've given a task to do a JUnit + JMock on a program created by other programmer. Most of the class has this static field logger, i.e.:
static Log logger = LogFactory.getLog(SomeClass.class.getName());
I am creating an instance of SomeClass by instantiating it inside my setUp()
method. When I run my jUnit class I am getting this error message:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: (No such file or directory)
I tried to do the the manual log4j configuration by calling DOMConfigurator.configure("log4j.xml");
inside the setUp()
method but I'm still getting the same error message above.
The question is:
- How can I run my unit test + mocking in a class which calls other class that uses LogFactory.getLog
- Should I configure log4j inside my setup method so that the mocking and unit test runs without an exception?
- How should I do it.