Skip to content

Latest commit

 

History

History

junit4

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Download from Maven Central

mockk-junit4

MockK Patterns for JUnit 4

Installation

Artifacts are hosted on the Maven Central repository.

Gradle Installation

repositories {
    mavenCentral()
}

dependencies {
    testImplementation("com.github.erikhuizinga:mockk-junit4:$LATEST_VERSION")
}

Usage

MockkTest

Extend this class to automatically apply MockkTestClassRule and MockkTestRule. These rules clear all MockK mocks after every unit test and unmock all MockK mocks after the test class.

MockK JUnit 4 test rules

MockkTestClassRule

Class rule to unmock all MockK mocks so that they don't leak between unit test classes.

MockkTestRule

Rule to clear all MockK mocks so that their state doesn't leak between unit test functions.

Example

Take a look at ExampleTestSuite for an example to use MockkTest with an extensive description of the involved MockK and JUnit 4 mechanics.