腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
当
Mockito
的
"
when
“
有
多个
”
thenReturn
“调
用时
,
这
意味着
什么
?
以下是从我正在进行
的
mockito
单元测试中提取
的
代码片段: .
thenReturn
(createJobStatus(JOB_ID, com.test.models.JobStatus.
浏览 28
提问于2017-07-04
得票数 1
回答已采纳
4
回答
mockito
中
的
动态链接"
thenReturn
“
、
、
、
、
我
有
一个元组模拟类,它
的
getString(0)和getString(1)方法将被调用n次。而不是写类似的东西,手动地,我尝试了以下操作: OngoingStubbing stubbingGetStringZero =
when
(tuple.getStr
浏览 1
提问于2014-07-29
得票数 18
回答已采纳
3
回答
通过
mockito
创建一个模拟列表
、
、
、
、
我想创建一个模拟列表来测试下面的代码: //code here下面是我
的
实现: }} 但是
当
测试运行
浏览 1
提问于2013-08-29
得票数 38
回答已采纳
3
回答
莫基托-是否
有
“价值不在列表中”
的
匹配者?
、
、
、
我目前有一个模拟,它对特定
的
输入集
有
特定
的
行为。每个其他输入都应该返回特定
的
响应。例如:
Mockito
.
when
(classInstance.myFunc(
Mockito
.eq("Option2&
浏览 0
提问于2018-08-14
得票数 4
回答已采纳
1
回答
Mockito
谓词JPA未正确运行
、
、
、
、
); .
thenReturn
(redFoxQuery);
Mockito
.
when
(redFoxCriteriaQuery.orderBy(
Mockito
.anyList())).
thenReturn
(redFoxCriteriaQuery("isDelet
浏览 6
提问于2020-07-20
得票数 2
回答已采纳
2
回答
Groovy 2.x和
Mockito
在一起玩得不太好
、
、
、
、
我试图为一些使用访问RESTful web服务
的
代码编写一些单元测试,并使用模拟一些事情。
Mockito
.
when
(mockResource.get(
Mockito
.any())).
thenReturn
(mockAddress) <omitted for
当
它运行时,我得到: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method com.s
浏览 4
提问于2014-12-06
得票数 3
回答已采纳
2
回答
eq()方法在单元测试中
的
应用
、
、
、
、
call the updateBook method thenVerifyBook();
when
(bookRepository.updateBook(bookId,any()).
thenReturn
(Optional.ofNullable(expectedBook));所有其他方法都可以正常工作test正在成功运行,但我无法理解eq()
的
含义。有人能解释一下以前
的
方法和修改
的
方法之间<e
浏览 6
提问于2022-07-25
得票数 1
2
回答
用
mockito
测试周围
的
试捕方法
、
、
、
、
有
什么
想法吗?,我用
的
是摩托。@Test
Mockito
.
when
(productRepository.saveProduct(buildProduct())).
thenReturn
(buildProduct()); void saveProductException()
浏览 9
提问于2021-01-28
得票数 1
回答已采纳
1
回答
什么
时候可以编写
Mockito
.anyInt()?
我
的
理解是:Assert.assertEquals("Foo Bar",list.get(7));
Mockito
.anyInt();
Mockito
.
when
(list.get(13)).
thenReturn
("Foo Bar&
浏览 0
提问于2015-06-24
得票数 1
3
回答
Mockito
:使用"
thenReturn
“中
的
方法返回模拟不起作用
、
、
、
我遇到了我认为可能是
Mockito
的
错误,但我想知道是否有人可以解释为
什么
这个测试不能工作。;
当
thenReturn
包含对此方法
的
直接调用以设置和获取第二个对象
的
模拟时,它将失败:public void notWorkingTest() {
浏览 4
提问于2015-12-01
得票数 52
回答已采纳
1
回答
使用链式OngoingStubbing
Mockito
?
、
、
、
、
在
Mockito
中,当我们试图模拟一个方法调
用时
,假设我们配置了如下内容
when
(exampleClass.getOutputString(anyString())).
thenReturn
("output1但是我
的
问题是,这个
thenReturn
("output1")方法返回一个OngoingStrubbing对象(与
when
(exampleClass.getOutputString(anyString()))方法返回
的
浏览 21
提问于2020-05-12
得票数 0
回答已采纳
1
回答
存根链式函数调用产生NullPointerException
、
、
在我
的
Spring项目中,我
有
测试,我想存根一个链式函数调用。request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));在我
的
单元测试中,我使用
Mockito
} 当我运行这个测试时,我得到了NullPointerException作为代码行
的
when
(mockedRequest.getReader().lines().collect(Collectors.joining(S
浏览 2
提问于2019-08-06
得票数 0
回答已采纳
2
回答
如何模拟从类级对象调用
的
方法
、
、
、
我正在为A类编写单元测试,我想模拟一个方法,但是这个方法是从类级对象中良性调用
的
,我将如何模拟这个方法。正在测试中
的
A类。;import org.powermock.core.classloader.annotations.PrepareForTest;
Mockito
.
when
(objB.performCalculation(5, 10)).<em
浏览 0
提问于2019-10-10
得票数 1
回答已采纳
1
回答
如何处理()和任何()方法?
、
、
下面的声明是做
什么
的
:我试着去找,但没有找到满意
的
答案。with(any(Long.class))和with(any(List.class))返回
什么
?
浏览 3
提问于2017-08-31
得票数 0
回答已采纳
2
回答
模拟方法没有被调用- java。
、
、
我是新来
的
莫基托,请帮助理解基本
的
。 intpublic sta
浏览 4
提问于2017-02-04
得票数 1
4
回答
Mockito
UnfinishedStubbingException
、
我是
Mockito
的
新手,我已经尝试过调查这个异常,但我还没有找到一个具体
的
答案。当我同时使用两个mock时,它就会在我
的
代码中发生,
这
意味着
我通过一个mock
的
构造函数给出了另一个mock。);
Mockito
.
when
(node.toString()).
th
浏览 31
提问于2013-03-22
得票数 25
回答已采纳
1
回答
为
什么
mockStatic
的
行为不符合预期?
、
、
、
、
@Test PowerMockito.mockStatic(ClassWithStatics.class);
Mockito
.
when
ClassWithStatics.getTime());}
浏览 5
提问于2017-02-09
得票数 1
回答已采纳
2
回答
使用
Mockito
测试在构造函数中需要字符串
的
类中
的
函数
、
、
我
有
以下类,并想为它编写单元测试。下面是完整
的
参考类。URISyntaxException { //some code }作为单元测试
的
新手,我对如何测试几乎一无所知,但这里
有
一个想法。请在不正确
的
地方纠正我。b)
Mockito
中是否
有
anyString()类型
的
功能,或者我是否应该使用其他功能?
浏览 2
提问于2014-10-17
得票数 0
1
回答
模拟方法出错
、
、
、
我试图模拟项目中
的
一些方法,以便在调用它们时返回某个值。但是,
当
您运行测试时,它们会随着输出而下降: 如果在调试模式下运行相同
的
代码并运行所有行,那么
当
调用shared.getToken ()时,将返回我们指定<e
浏览 2
提问于2017-11-07
得票数 0
回答已采纳
2
回答
调用模拟对象时
的
NPE (
Mockito
)
、
但是,
当
调用"builder.get()“时,我将得到一个空指针异常(构建器为空)。myResponseMock = mock(MyCustomResponse.class);
Mockito
.
when
builderMock = mock(Invocation.Builder.class);
Mockito
.
when
(builderMock.get()).
thenRetur
浏览 4
提问于2016-07-04
得票数 0
回答已采纳
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
实时音视频
对象存储
云直播
活动推荐
运营活动
广告
关闭
领券