选择JUnit Ant目标 [英] ant target for 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
该扩展延伸实习生的TestCase ESWTestCase,这使得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.<clinit>(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是有code 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 /罐的一个包括一个索引文件( 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 Ant目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!