Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nillerr/mockk-junit
https://github.com/nillerr/mockk-junit
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nillerr/mockk-junit
- Owner: Nillerr
- License: mit
- Created: 2023-06-25T17:43:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-27T08:05:59.000Z (4 months ago)
- Last Synced: 2024-08-28T08:26:45.698Z (4 months ago)
- Language: Kotlin
- Size: 73.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MockK for JUnit 5
Provides the `@MockKTest` annotation for running `checkUnnecessaryStub()` on all [MockK](https://mockk.io/) mock
instances stored in the member properties of the test class the annotation is present on.## Installation
```kotlin
dependencies {
implementation("io.github.nillerr:mockk-junit5:1.0.1")
}
```## Usage
Annotate a test class with the `@MockKTest` annotation:
```kotlin
@MockKTest
class UserServiceTests {
// Mocks
private val repository: UserRepository = mockk()
// SUT
private val service = UserService(repository)
@Test
fun test() {
// Given
val id = "5"
val account = AccountRecords.default
every { repository.find(id) }.returnsMany(account)
// When
val result = service.get(id)
// Then
assertEquals(result).isEqualTo(Accounts.default)
}
}
```JUnit will now call `checkUnnecessaryStub()` on the `UserRepository` after every test.