我想模拟返回 Class<? extends Annotation>
的方法 annotationType() .
但是下一行给我一个编译错误。
when(annotation.annotationType()).thenReturn(notNullClass.getClass());
我正在使用 java 1.7.0_45。我收到需要通过 Class<? extends Annotation>
的编译错误作为参数。
知道我应该把什么作为 thenReturn
的参数吗?为了编译?
最佳答案
annotation.annotationType()
返回 Class<? extends Annotation>
.
所以你必须返回一些注解类型的类对象。
关于java - Mockito:模拟 AnnotationType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31317575/