TypeNotPresentExceptionProxy

问题描述 投票:51回答:1

当从Surefire 2.6升级到Surefire 2.13时,我在运行单元测试时得到了TypeNotPresentExceptionProxy

java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
    at java.lang.Class.getAnnotation(Class.java:3029)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.isValidJUnit4Test(JUnit4TestChecker.java:64)

JUnit4TestChecker中,第64行看起来像这样:

Annotation runWithAnnotation = testClass.getAnnotation( runWith );

所以Surefire检查@RunWith注释以确保其类型有效。我们的测试使用Spring,所以@RunWith在我们的测试类中看起来像这样:

@RunWith(SpringJUnit4ClassRunner.class)

似乎Surefire没有找到SpringJUnit4ClassRunner类。我不确定为什么因为在Surefire 2.6下,测试运行良好。

有任何想法吗?

java maven exception junit surefire
1个回答
2
投票

运行mvn依赖:解决

排除可能已经悄悄进入的任何3.x版本的JUnit。

确保没有TestNG依赖项,如果有它将加载TestNG注释而不是您需要的JUnit注释。

© www.soinside.com 2019 - 2024. All rights reserved.