How can I mock an instance of an enum class with PowerMock amp; Mockito?(如何使用 PowerMock amp; 模拟枚举类的实例莫基托?)
问题描述
我尝试按照这个非常相似的问题的答案中提供的示例进行操作,但它对我不起作用.我收到以下错误消息:
I tried to follow the example offered in the answer to this very similar question, but it does not work for me. I get the following error message:
我需要一个 枚举类
的简单模拟实例.我不需要模拟它的任何方法.
I need a simple mock instance of an enum class
. I don't need to mock any of its methods.
这是我要模拟的课程:
我有以下 TestNG 设置:
I have the following TestNG setup:
推荐答案
我通过扩展 PowerMockTestCase 类来为 TestNG 处理这种事情:
I got this working by extending the PowerMockTestCase class that handles this kind of thing for TestNG:
这篇关于如何使用 PowerMock & 模拟枚举类的实例莫基托?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!