junit 的蚂蚁目标 [英] ant target for junit

查看:29
本文介绍了junit 的蚂蚁目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Suite.java 文件:

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 文件扩展了 TestCase,它工作正常.但是 ProductServiceTest.java

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

扩展 ESWTestCase 实习生扩展 TestCase,这会导致 junit atrget 失败.

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>
  <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 有代码suite.addTestSuite(ProductServiceTest.class);Log4j被引用为:

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?

推荐答案

检查您的 jar/其中一个 jar 是否包含索引文件 (META_INF/INDEX.LIST).如果是,请查看它,它可能包含无效的索引条目.

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.

这里有一篇关于您的异常的文章:为什么会发生 InvalidJarIndexException?

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

这篇关于junit 的蚂蚁目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆