For those of you following this thread....
so I changed my JUnit code so the ProjectTestSuite ran the test classes
using Textui instead of Swingui and voila!!! it worked. The original was:
public class ProjectTestSuite extends TestCase {
static Logger logger= Logger.getLogger(ProjectTestSuite.class);
public ProjectTestSuite(String name) {
super(name);
}
public static Test suite() {
TestSuite theSuite = new TestSuite();
theSuite.addTest(com.growlingcow.aviation.AviationPackageSuite.suite());
theSuite.addTest(com.growlingcow.utilities.UtilitiesPackageTestSuite.suite()
);
return theSuite;
}
public static void main(String[] argv) {
PropertyConfigurator.configure("log4j.properties");
logger.info("In main method for " +
ProjectTestSuite.class.toString());
String[] testCaseList = {ProjectTestSuite.class.getName()};
junit.swingui.TestRunner.main(testCaseList); // This is apparently
the offending line.
}
}
I changed the code within main to call JUnit in multiple ways and in all
cases the swingui method of running Junit failed when run with log4j. The
code I used with comments is below.
/** Executes the test case */
public static void main(String[] argv) {
// PropertyConfigurator.configure("log4j.properties");
System.out.println("log4j.configuration[ProjectTestSuite] " +
System.getProperty("log4j.configuration"));
logger.info("In main method for " +
ProjectTestSuite.class.toString());
String[] testCaseList = {ProjectTestSuite.class.getName()};
System.out.println("TestCaseList");
for (int i = 0; i < testCaseList.length; i++)
System.out.println(testCaseList[i]);
// junit.swingui.TestRunner.main(testCaseList); //Junit
works but Fails log4j
// junit.swingui.TestRunner.run(ProjectTestSuite.class);//Junit
works but Fails log4j
// junit.textui.TestRunner.run(ProjectTestSuite.class); // Fails but
not because of log4j - no test defined in class
// junit.textui.TestRunner.main(testCaseList); //works
junit.textui.TestRunner.run(suite()); // Works
}
Output of running below
E:\working\aviation>java -cp
./classes;./bin/junit3.7/junit.jar;./bin/jakarta-log4j-1.2.8/dist/lib/log4j-
1.2.8.jar -Dlog4j.configura
tion=file:/e:/working/aviation/log4j.properties
com.growlingcow.ProjectTestSuite
log4j.configuration[ProjectTestSuite]
file:/e:/working/aviation/log4j.properties
(ProjectTestSuite.java:46) INFO com.growlingcow.ProjectTestSuite - In main
method for class com.growlingcow.ProjectTestSuite
TestCaseList
com.growlingcow.ProjectTestSuite
.(Abbreviation.java:76) DEBUG
om.growlingcow.aviation.cfs.data.Abbreviation - In private constructor for
Abbreviation
(Abbreviation.java:79) DEBUG
om.growlingcow.aviation.cfs.data.Abbreviation - Exiting private constructor
for Abbreviation
log4j.configuration [Abbrev] file:/e:/working/aviation/log4j.properties
(Abbreviation.java:67) DEBUG
om.growlingcow.aviation.cfs.data.Abbreviation - In getInstance for class
com.growlingcow.aviation.cfs
.data.Abbreviation
.log4j.configuration [Abbrev] file:/e:/working/aviation/log4j.properties
(Abbreviation.java:67) DEBUG
om.growlingcow.aviation.cfs.data.Abbreviation - In getInstance for class
com.growlingcow.aviation.cfs
.data.Abbreviation
.......................................
...........data/Abbreviations.dat
data/NOTAMAbbreviations.dat
....fake Key
Time: 0.09
OK (56 tests)
E:\working\aviation>
While this works, it is irritating (to say the least). Any idea's from the
JUnit experts or anyone who has done this before with log4j would be nice!
Cheers (I think I really will go have a beer now )
Cam
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]