gpt4 book ai didi

java - Mockito:模拟 AnnotationType

转载 作者:搜寻专家 更新时间:2023-11-01 03:20:42 24 4
gpt4 key购买 nike

我想模拟返回 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com