awesome-repositories.com
Blog
MCP
awesome-repositories.com

Découvrez les meilleurs dépôts open-source grâce à notre recherche par IA.

ExplorerRecherches sélectionnéesAlternatives open sourceLogiciels auto-hébergésBlogPlan du site
ProjetÀ proposNotre méthodologiePresseServeur MCP
Mentions légalesConfidentialitéConditions d'utilisation
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
mockk avatar

mockk/mockk

0
View on GitHub↗
5,747 stars·410 forks·Kotlin·Apache-2.0·5 vuesmockk.io↗

Mockk

MockK is a Kotlin test double framework that creates mocks, spies, and relaxed mocks for unit testing, with support for final classes, static methods, and coroutines. It functions as a bytecode instrumentation library that modifies compiled class files at load time to intercept constructors, final methods, and static functions without source changes, and also provides dedicated libraries for constructor mocking and coroutine mocking. The framework is designed specifically for Kotlin, handling Kotlin-specific constructs like extension functions, singletons, and suspend functions.

MockK distinguishes itself through comprehensive test double creation and verification capabilities, including stubbing, argument capture, call count and order verification, and support for various Kotlin constructs. It offers flexible argument matching with custom matchers, chained call stubbing, and dynamic answer provision. The framework supports both strict and relaxed mock creation, where relaxed mocks return default values for unstubbed calls, and provides spy wrapping that allows selected methods to be stubbed while others execute their original implementation. MockK also includes Android instrumented test support, using DexOpener to make final classes subclassable on pre-Android P devices and inline instrumentation on P+.

The framework provides extensive verification features including timeout-based verification for concurrent code, full call verification, unnecessary stub detection, and call recording exclusion. It supports mocking of private members, enum constants, object instances, and singleton objects, along with initialization block suppression and superclass call suppression. MockK offers annotation-based mock initialization with JUnit rule lifecycle management, automatic mock injection, and global configuration defaults that can be set project-wide through configuration files or system properties.

Features

  • Test Double Libraries - Creates a test double for any class and lets you stub its methods to return specific values.
  • Kotlin Unit Testing - Creates lightweight mock objects to isolate and verify behavior of Kotlin code during unit tests.
  • Bytecode and Instrumentation - Modifies compiled class files at load time to intercept constructors, final methods, and static functions without source changes.
  • Mock Argument Capturers - Records actual arguments passed to stubbed methods for later inspection or assertion in tests.
  • Mocking Libraries - Creates test doubles for Kotlin classes, including final classes, static methods, and coroutines, without modifying production code.
  • Return Value Configurations - Defines what a mocked method should return when called with specific arguments.
  • Bytecode Instrumentation Agents - Modifies compiled class files at load time to intercept constructors, final methods, and static functions without source changes.
  • Suspend Function Stubbings - Stubs and verifies suspend functions and coroutine-heavy code, enabling controlled asynchronous behavior in tests.
  • Load-Time Class Transformations - Modifies compiled class files during class loading to intercept constructors, final methods, and static functions without source changes.
  • Lambda Argument Capturers - Captures lambda arguments passed to mocked functions for post-execution inspection during tests.
  • Extension and Constructor Function Mockings - Intercepts constructor calls and stubs suspend functions to test code that creates objects or uses coroutines internally.
  • Static Function Mockings - Replaces static and top-level Kotlin functions with mocks for stubbing and verification in tests.
  • Static Method Mockings - Replaces static and extension function calls with controlled behavior for test isolation.
  • Top-Level Function Stubs - Replaces standalone Kotlin functions with mocks for testing code that calls them.
  • Lambda Argument Captures for Mocks - Captures lambda arguments and mocks suspend functions so coroutine-heavy code is testable without a real dispatcher.
  • Mock Call Order Verifications - Asserts that interactions with a mock happened in a specific sequence, or that no unexpected calls occurred.
  • Chained Call Answer Providers - Returns a nested mock or value when a chain of method calls is invoked on a mock.
  • Method Stubbings - Defines what a mock returns or does when a specific method is called, including chained calls and multiple answers.
  • Static or Top-Level Function Stubs - Replaces static methods and top-level functions with stubs for the duration of a test.
  • Method Invocation Verifications - Asserts that a mocked method was called a specific number of times, or within a minimum and maximum range.
  • Chained Call Stubbers - Stubs a sequence of property or method accesses on a mock, returning nested mocks for intermediate steps.
  • Kotlin Construct Mocks - Mocks Kotlin-specific constructs like objects, static methods, coroutines, and extension functions in Android instrumented tests.
  • Singleton Object Mocks - Replaces Kotlin singleton objects with mocks for the duration of a test, restoring originals afterward.
  • Singleton Object Replacements - Replaces Kotlin singleton objects with mocks for the duration of a test, restoring originals afterward.
  • Constructor Interceptors - Intercepts constructor calls to return mock instances, useful for testing code that creates objects internally.
  • Relaxed Mocks - Creates relaxed mocks that return default values for unstubbed calls, reducing test boilerplate.
  • Final Member Mocks - Overrides final and closed classes during tests, removing the usual restriction on subclassing them.
  • Static Member Mocks - Mocks final classes, object instances, and static methods using bytecode instrumentation to isolate tests from real implementations.
  • Unit Testing - Enables isolated unit testing by creating lightweight mock objects that simulate real dependencies.
  • Method Interception Spies - Wraps real objects so unstubbed methods execute original implementations while stubbed methods return configured values.
  • Suspend Function Interceptions - Intercepts Kotlin suspend function calls at the bytecode level to allow stubbing and verification of coroutine-based methods.
  • Test Double Frameworks - Creates mocks, spies, and relaxed mocks that support Kotlin-specific features like extension functions, constructors, and singletons.
  • Dynamic Mock Answer Providers - Returns computed or dynamic results from stubbed methods based on call arguments or internal state.
  • Mock Null Value Handlings - Handles null values in mocks by returning null or accepting null arguments for nullable type coverage.
  • Mock Lifecycle Scopes - Manages mock lifecycle within lexical scopes, automatically clearing interactions after scope exit.
  • Concurrent Operation Verifications - Waits up to a timeout for verification to pass, enabling testing of code running on other threads.
  • Test Lifecycle Rules - Uses a JUnit rule or extension to automatically initialize and clean up mocks per test class.
  • Private Member Stubs - Stubs and verifies private methods and properties on spies using dynamic call syntax.
  • Mock Argument Matchers - Uses matchers to specify acceptable argument values when stubbing or verifying, including wildcards and custom predicates.
  • Matcher Expressions - Writes concise expressions that match arguments by condition such as equality, type, or custom predicates.
  • Partial Argument Matchers - Specifies argument matchers for only some parameters of a call, leaving others to match any value automatically.
  • Mock Backing Field Accessors - Overrides the value stored in a property's backing field on a mock, bypassing getter and setter logic.
  • Call Recording Exclusions - Ignores specified method calls during exhaustive verification so they do not cause failures.
  • Concurrent Call Verifications - Waits for verification to pass within a timeout, enabling testing of asynchronous or multi-threaded code.
  • Exhaustive Call Verifications - Checks that every recorded call on a mock has been covered by a verification statement.
  • Sequenced Call Answer Providers - Supports returning a sequence of different values from a stubbed method across successive calls.
  • Property Backing Field Overrides - Reads or modifies the backing field of a property during stubbing or verification.
  • BDD Syntax Aliases - Writes test stubs and verifications using given/when/then syntax for behavior-driven development.
  • Mock State Resetting - Resets internal recording and stubbing state of mocks without removing their bytecode transformations.
  • Global Mock Restorations - Restores all mocked objects, statics, and constructors to their original state after test execution.
  • Array Type Mock Definitions - Stubs methods that accept or return arrays, handling array types correctly in mock definitions.
  • Annotation-Driven Mock Injections - Declares mocks, spies, and injected mocks with annotations and initializes them automatically in a setup method.
  • Mock Strictness Dispatchers - Creates mocks that require explicit behavior definitions for every call and fail on unexpected invocations.
  • Android Instrumented Mock Objects - Provides mock objects designed for Android instrumented test environments with platform-specific adaptation.
  • Initialization Block Suppressors - Suppresses the execution of class initialization blocks when creating mock objects to prevent side effects.
  • Instance-Level Mock Replacements - Replaces behavior on specific object instances at runtime to verify interactions on real objects.
  • Nested Mock Builders - Builds a tree of nested mocks in a single DSL block, defining behavior for deeply nested properties concisely.
  • Mock Restorations - Restores individual mocked classes, objects, or static methods back to their original implementations.
  • Android Final Class Mocks - Mocks final classes in Android instrumented tests using DexOpener on pre-P and inline instrumentation on P+.
  • Private Function Overrides - Overrides private method implementations on mocks to control internal behavior during tests.
  • Private Method Stubs - Stubs or verifies private methods on spies using dynamic call syntax for complete code isolation.
  • Custom Matchers - Provides a DSL for defining custom argument matchers using the match helper function or Matcher interface.
  • Vararg Method Stubbers - Stubs and verifies methods that accept variable-length argument lists.
  • Timeout-Based Verifications - Waits for verification to pass within a time limit, enabling testing of concurrent code.
  • Frameworks de test - Mocking library for Kotlin.
  • Testing & Quality Assurance - mocking library for Kotlin

Historique des stars

Graphique de l'historique des stars pour mockk/mockkGraphique de l'historique des stars pour mockk/mockk

Recherche par IA

Explorez plus de dépôts awesome

Décrivez vos besoins en langage naturel — l'IA classe des milliers de projets open source sélectionnés par pertinence.

Start searching with AI

Questions fréquentes

Que fait mockk/mockk ?

MockK is a Kotlin test double framework that creates mocks, spies, and relaxed mocks for unit testing, with support for final classes, static methods, and coroutines. It functions as a bytecode instrumentation library that modifies compiled class files at load time to intercept constructors, final methods, and static functions without source changes, and also provides dedicated libraries for constructor mocking and coroutine mocking. The framework is designed specifically…

Quelles sont les fonctionnalités principales de mockk/mockk ?

Les fonctionnalités principales de mockk/mockk sont : Test Double Libraries, Kotlin Unit Testing, Bytecode and Instrumentation, Mock Argument Capturers, Mocking Libraries, Return Value Configurations, Bytecode Instrumentation Agents, Suspend Function Stubbings.

Quelles sont les alternatives open-source à mockk/mockk ?

Les alternatives open-source à mockk/mockk incluent : powermock/powermock — Powermock is a Java mocking framework and unit testing tool that uses bytecode manipulation to mock static methods,… devlooped/moq — Moq is a .NET mocking framework and C# library used to create simulated objects and interfaces. Its primary purpose is… golang/mock — GoMock is a mocking framework for the Go programming language. codeception/codeception — Codeception is a full-stack testing framework for PHP applications that provides a unified interface for unit,… sapegin/jest-cheat-sheet — This project is a comprehensive reference guide and cheat sheet for the Jest testing framework. It provides technical… sebastianbergmann/phpunit-mock-objects — This project is a mocking framework and library designed for creating simulated objects to isolate code and verify…

Alternatives open source à Mockk

Projets open source similaires, classés selon le nombre de fonctionnalités partagées avec Mockk.
  • powermock/powermockAvatar de powermock

    powermock/powermock

    4,174Voir sur GitHub↗

    Powermock is a Java mocking framework and unit testing tool that uses bytecode manipulation to mock static methods, final classes, and private constructors. It includes a Java agent instrumentation tool and a reflection-based testing utility to bypass encapsulation and modify class behavior at runtime. The project distinguishes itself by providing the ability to intercept the instantiation of objects via the new keyword and simulate the behavior of core Java system classes and native methods. It can override final modifiers on classes and methods and bypass signature restrictions for classes

    Java
    Voir sur GitHub↗4,174
  • devlooped/moqAvatar de devlooped

    devlooped/moq

    6,389Voir sur GitHub↗

    Moq is a .NET mocking framework and C# library used to create simulated objects and interfaces. Its primary purpose is to isolate code from external dependencies during unit testing by providing a system for interface simulation and behavioral testing. The framework distinguishes itself through the use of functional specification queries and LINQ-based querying to create declarative mocks. It supports the simulation of complex scenarios, including the automatic generation of recursive mock hierarchies, the implementation of multiple interfaces within a single mock instance, and the ability to

    C#
    Voir sur GitHub↗6,389
  • golang/mockAvatar de golang

    golang/mock

    9,361Voir sur GitHub↗

    GoMock is a mocking framework for the Go programming language.

    Go
    Voir sur GitHub↗9,361
  • codeception/codeceptionAvatar de Codeception

    Codeception/Codeception

    4,855Voir sur GitHub↗

    Codeception is a full-stack testing framework for PHP applications that provides a unified interface for unit, functional, and acceptance testing. It serves as a tool for automating real desktop and mobile browsers via the WebDriver protocol and acts as a client for testing REST and SOAP APIs. The framework is distinguished by its support for Behavior-Driven Development, allowing users to write human-readable test specifications in Gherkin language to align technical tests with business requirements. It implements actor-based action mapping to connect these natural language steps to executabl

    PHP
    Voir sur GitHub↗4,855
  • Voir les 30 alternatives à Mockk→