MockKExtension

class MockKExtension : TestInstancePostProcessor, ParameterResolver, AfterAllCallback

JUnit5 extension.

Parameters can use MockK and RelaxedMockK. Class properties can use MockK, RelaxedMockK and SpyK will be called after test class execution (*)

Usage: declare @ExtendWith(MockKExtension.class) on a test class

Alternatively –Djunit.extensions.autodetection.enabled=true may be placed on a command line.

(*) unmockkAll default behavior can be disabled by adding KeepMocks to your test class or method or –Dmockk.junit.extension.keepmocks=true on a command line

Constructors

Link copied to clipboard
fun MockKExtension()

Types

Link copied to clipboard
annotation class CheckUnnecessaryStub
Link copied to clipboard
object Companion
Link copied to clipboard
annotation class ConfirmVerification
Link copied to clipboard
annotation class KeepMocks

Prevent calling unmockkAll after each test execution

Functions

Link copied to clipboard
open override fun afterAll(context: ExtensionContext)
Link copied to clipboard
open override fun postProcessTestInstance(testInstance: Any, context: ExtensionContext)
Link copied to clipboard
open override fun resolveParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Any?
Link copied to clipboard
open override fun supportsParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Boolean