开发者

ant target for junit

i have Suite.java file as:

public class EshopServiceTestSuite extends TestSuite {

    public static Test suite() {
        TestSuite suite = new TestSuite();
        suite.addTestSuite(ImpactActionTypeTest.class);
        suite.addTestSuite(ProductServiceTest.class);
        return suite;
    }
    public static void main(String[] args) {
         TestRunner.run(EshopServiceTestSuite .class);
    }

}

ImpactActionTypeTest.java file extends TestCase it is working fine. But ProductServiceTest.java

extends ESWTestCase which intern extends TestCase, this causes junit atrget to fail.

<error type="java.lang.reflect.InvocationTargetException">java.lang.reflect.InvocationTargetException
Caused by: java.lang.ExceptionInInitializerError
    at org.apache.log4j.Logger.getLogger(Logger.java:94)
    at com.bgc.ecm.core.test.ElNinoAbstractTestCase.&lt;clinit&gt;(ElNinoAbstractTestCase.java:62)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at com.bgc.EshopServiceTestSuite.suite(EshopServiceTestSuite.java:41)
Caused by: sun.misc.InvalidJarIndexException: Invalid index
    at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:769)
    .....

</error>
  &开发者_开发技巧lt;system-out><![CDATA[]]></system-out>
  <system-err><![CDATA[log4j:WARN Caught Exception while in Loader.getResource. This may be innocuous.
sun.misc.InvalidJarIndexException: Invalid index

EshopServiceTestSuite.java:41 is having code suite.addTestSuite(ProductServiceTest.class); Log4j is refered as:

- C:\build_libs\ESW\junit-3.8.1.jar
- C:\build_libs\ESW\log4j-1.2.15.jar
- C:\build_libs\ESW\log4j-1.2.8.jar
- C:\build_libs\ESW\mailapi.jar

why this exception is occuring?


It looks like the class loader is looking for a class file in some jar and can't find it.

As your talking of .java files only - double check that all files have been compiled and added to the jar file.

Just saw that the exception occured in log4j - double-check that log4j.jar is on the class path while the test is executed.


Check if your jar / one of your jars includes an index file (META_INF/INDEX.LIST). If yes, have a look at it, it may contain invalid index entries.

Here's an article about your exception: Why does InvalidJarIndexException occur?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜