diff --git a/README.md b/README.md index bd7022372bc2eb848207baf36edbf91422ee85e8..11f49cdc64ea842b6a467f385c566256e724d864 100644 --- a/README.md +++ b/README.md @@ -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(...) |builds a regular mock| +|spyk() |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