问题描述
我正在尝试运行一个使用Mockito的JUnit Cucumber测试。这是我遇到的问题。在我的Cucumber Runner类中,我有
I'm trying to run a JUnit Cucumber test that uses Mockito. Here's the issue I'm running into. In my Cucumber Runner class, I have
@RunWith(Cucumber.class)
在我的常规JUnit测试中,
And in my regular JUnit tests I have
@RunWith(Mockito.class)
鉴于我一次只能拥有一个@RunWith,如何我可以将Mockito与Cucumber结合使用吗?
Given that I can only have one @RunWith at a time, how can I use Mockito in conjunction with Cucumber?
推荐答案
是的,您可以同时使用Cucumber和Mockito。
Yes, you can use Cucumber and Mockito at the same time.
您不能同时使用两个JUnit运行器。但是,如果您将Mockito添加为项目的依赖项,并像这样创建模拟: List mockedList =模拟(List.class);
,那么您应该能够组合工具
You can't use two JUnit runners at the same time. But if you add Mockito as a dependency to your project and create your mocks like this: List mockedList = mock(List.class);
then you should be able to combine the tools.
更多信息,请参见
这篇关于使用Mockito运行黄瓜测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!