Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
颯沓如流星
mockk
提交
fe3f2121
M
mockk
项目概览
颯沓如流星
/
mockk
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mockk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fe3f2121
编写于
10月 22, 2020
作者:
颯沓如流星
🎨
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: README.md
上级
e7e1b895
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
3 deletion
+38
-3
README.md
README.md
+38
-3
未找到文件。
README.md
浏览文件 @
fe3f2121
...
...
@@ -22,7 +22,8 @@ fun testAdd() {
```
`MockK`
是一个用 Kotlin 写的 Mocking 框架,它解决了所有上述提到的 Mockito 中存在的问题。
[
`MockK` 是一个用 Kotlin 写的 Mocking 框架
](
https://mockk.io/
)
,它解决了所有上述提到的 Mockito 中存在的问题。
## MockK
...
...
@@ -253,7 +254,7 @@ class GoodsPresenterTest {
}
```
##
#
添加依赖
## 添加依赖
```
kotlin
// Unit tests
testImplementation
"io.mockk:mockk:1.9.3"
...
...
@@ -265,4 +266,38 @@ androidTestImplementation 'org.objenesis:objenesis:2.6'
// Coroutine tests
implementation
'
org
.
jetbrains
.
kotlinx
:
kotlinx-coroutines-android
:
1.3.0
-
M2
'
testImplementation
'
org
.
jetbrains
.
kotlinx
:
kotlinx-coroutines-test
:
1.3.0
-
M2
'
```
\ No newline at end of file
```
## Top level functions
|Function|Description|
|--|--|
|mockk
<T>
(...) |builds a regular mock|
|spyk
<T>
() |builds a spy using the
`default constructor`
|
|spyk(obj)| builds a spy by
`copying from obj`
|
|slot |creates a capturing slot|
|every |starts a stubbing block|
|coEvery |starts a stubbing block for coroutines|
|verify |starts a verification block|
|coVerify |starts a verification block for coroutines|
|verifyAll |starts a verification block that should include all calls|
|coVerifyAll |starts a verification block that should include all calls for coroutines|
|verifyOrder |starts a verification block that checks the order|
|coVerifyOrder |starts a verification block that checks the order for coroutines|
|verifySequence |starts a verification block that checks whether all calls were made in a specified sequence|
|coVerifySequence |starts a verification block that checks whether all calls were made in a specified sequence for coroutines|
|excludeRecords |exclude some calls from being recorded|
|confirmVerified |confirms that all recorded calls were verified|
|clearMocks |clears specified mocks|
|registerInstanceFactory |allows you to redefine the way of instantiation for certain object|
|mockkClass |builds a regular mock by passing the class as parameter|
|mockkObject |makes an object an object mock or clears it if was already transformed|
|unmockkObject |makes an object mock back to a regular object|
|mockkStatic |makes a static mock out of a class or clears it if it was already transformed|
|unmockkStatic |makes a static mock back to a regular class|
|clearStaticMockk |clears a static mock|
|mockkConstructor |makes a constructor mock out of a class or clears it if it was already transformed|
|unmockkConstructor |makes a constructor mock back to a regular class|
|clearConstructorMockk |clears the constructor mock|
|unmockkAll |unmocks object, static and constructor mocks|
|clearAllMocks |clears regular, object, static and constructor mocks|
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录