Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pegasystems/mmock
Kotlin Multiplatform Mock Framework
https://github.com/pegasystems/mmock
kotlin-multiplatform mocking
Last synced: about 2 months ago
JSON representation
Kotlin Multiplatform Mock Framework
- Host: GitHub
- URL: https://github.com/pegasystems/mmock
- Owner: pegasystems
- License: apache-2.0
- Created: 2020-09-09T16:03:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-08T15:15:31.000Z (over 1 year ago)
- Last Synced: 2024-04-17T22:47:49.755Z (9 months ago)
- Topics: kotlin-multiplatform, mocking
- Language: Kotlin
- Homepage:
- Size: 490 KB
- Stars: 10
- Watchers: 8
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# MMock - mocking library for Kotlin Multiplatform
[![Build Status](https://travis-ci.org/pegasystems/mmock.svg?branch=master)](https://travis-ci.org/pegasystems/mmock)
![badge](https://img.shields.io/badge/platform-JVM-orange)
![badge](https://img.shields.io/badge/platform-JS-red)
![badge](https://img.shields.io/badge/platform-iOS--64-yellow)
![badge](https://img.shields.io/badge/platform-Android-brightgreen)
![badge](https://img.shields.io/badge/platform-Linux--64-blue)
![badge](https://img.shields.io/badge/platform-MinGW--64-blueviolet)Multiplatform Kotlin library for mocking.
## How to use
1\. Add plugin to gradle:```build.gradle.kts
plugins {
// ...
id("com.pega.mmock") version
}// ...
kotlin {
// ...
sourceSets {
val commonMain by gettting {
dependencies {
// ...
implementation("com.pega.mmock:mmock-runtime:$mmockVersion")
}
}
}
}
```2\. Annotate interface
```kotlin
package com.exampleimport com.pega.mmock.GenerateMock
@GenerateMock
interface MyInteface {
fun myFunction(arg1: Int): Int
}
```3\. Use mocks in tests
```kotlin
package com.exampleimport com.pega.mmock.dsl.any
import com.pega.mmock.dsl.once
import com.pega.mmock.withMMockclass TestClass {
@Test
fun exampleTest() = withMMock {
val myInterface = mock.MyInterface()
every { myInterface.myFunction(any()) } returns 2assertEquals(2, myInterface.myFunction(1))
verify {
invocation { myInterface.myFunction(any()) } called once
}
}
}
```For more detailed user guide go to [usage.md](docs/usage.md)