Thomas, Here's an example:
import org.apache.log4j.Category; import org.apache.log4j.BasicConfigurator; import junit.framework.Test; import junit.framework.TestSuite; import junit.framework.TestCase; import junit.framework.Assert; /** * JUnit test with log4j. Note: This is 1.1.3 code. */ public class TestLog4j extends TestCase { public TestLog4j(String name) { super(name); } public static void main(String [] args) { junit.swingui.TestRunner.run(TestLog4j.class); } public void setUp() { // clear everything out BasicConfigurator.resetConfiguration(); // You can do whatever you like -- XML config with DOMConfigurator, Props file // with PropertyConfigurator. I usually hard-code the full config here rather // than using a file to avoid problems with where the config file goes for // testing. BasicConfigurator.configure(); } public static Test suite() { return new TestSuite(TestLog4j.class); } public void testError() throws Exception { // log4j 1.1.3 syntax Category cat = Category.getInstance(getClass().getName()); assertNotNull("Category was null", cat); cat.error("Error string"); } public void testWarn() throws Exception { // log4j 1.1.3 syntax Category cat = Category.getInstance(getClass().getName()); assertNotNull("Category was null", cat); cat.warn("Warning string"); } } > Could you point me where I could find more information with respect to your > proposal because I do not see what I should do ! > > Rgds, > >Thomas, > >> Is this happening because you configure log4j in your setUp methods? If so, >> two ways to fix it. >> >> 1) Use the junit.extensions.TestSetup decorator and put your configuration >> in its setUp. >> 2) Call BasicConfigurator.resetConfiguration just before doing your >> configuration to clean up anything from previous tests. >> >>> Does some one uses Log4J & JUnit toghether ? >>> If yes, How does he /she do to avoid double loading of the Appender when running the >>> suite() ? -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>