{"id":18783987,"url":"https://github.com/anthonycr/mockingbird","last_synced_at":"2026-01-06T01:16:09.001Z","repository":{"id":227760558,"uuid":"772328034","full_name":"anthonycr/Mockingbird","owner":"anthonycr","description":"A minimalist faking framework exclusively for verifying interactions","archived":false,"fork":false,"pushed_at":"2024-10-24T04:11:59.000Z","size":298,"stargazers_count":3,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-24T18:19:11.558Z","etag":null,"topics":["kotlin","mock","testing","verification"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anthonycr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-15T01:15:35.000Z","updated_at":"2024-10-24T04:11:44.000Z","dependencies_parsed_at":"2024-05-09T01:25:30.856Z","dependency_job_id":"e2ce3fa7-5037-4b4e-ae1d-11b55ac8c765","html_url":"https://github.com/anthonycr/Mockingbird","commit_stats":null,"previous_names":["anthonycr/mockingbird"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycr%2FMockingbird","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycr%2FMockingbird/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycr%2FMockingbird/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycr%2FMockingbird/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthonycr","download_url":"https://codeload.github.com/anthonycr/Mockingbird/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223588502,"owners_count":17169877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","mock","testing","verification"],"created_at":"2024-11-07T20:41:31.223Z","updated_at":"2026-01-03T21:16:57.576Z","avatar_url":"https://github.com/anthonycr.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mockingbird\n\nA minimalist faking framework exclusively for verifying interactions. It generates fake\nimplementations of interfaces and abstract classes that can be verified during a test using the\nKotlin compiler plugin API. It does not allow mocking behavior or return values, and does not\nsupport mocking concrete classes.\n\n## Why?\n\nOther testing frameworks exist, like MockK, that support full mocking of all types, a wide range of\nfeatures, and have significantly more utility than this minimalist framework. However, mocking\nobjects is frequently viewed as an anti-pattern, as mocking an object can cover up poor class design\nby making untestable code testable. Tests that heavily utilize mocks can lose their utility and even\nobscure bugs, or can become difficult to understand and refactor. Additionally, mocks are usually\nslow to construct, which in turn slows down test execution.\n\nFakes are less forgiving then mocks and require better class design in order to support testing.\nBecause they are less flexible, they have less potential to be abused. However, it can be annoying\nto verify interactions on fakes because they are usually handwritten. Mockingbird auto-generates\nfake implementations of interfaces and abstract classes that have `Unit` function types - types\nusually performing side effects that are most often verified by a mocking framework.\n\n## Usage\n\n![Maven Central Version](https://img.shields.io/maven-central/v/com.anthonycr.mockingbird/core)\n\nMockingbird is available on Maven Central and through the Gradle Plugin Portal. Include the\nfollowing dependencies in your `build.gradle.kts` file.\n\n```kotlin\nplugins {\n    kotlin(\"jvm\") version \"\u003clatest_version\u003e\"\n    id(\"com.anthonycr.plugins.mockingbird\") version \"\u003clatest_version\u003e\"\n}\n```\n\nThen add the build dependencies to the `dependencies` block.\n\n```kotlin\ndependencies {\n    testImplementation(\"com.anthonycr.mockingbird:core:\u003clatest_version\u003e\")\n}\n```\n\nWithin your test, add the following annotation to a property that you wish to verify. Note that the\nproperty you are verifying must be an interface or abstract class with a zero argument constructor.\nAll functions you wish to verify must return `Unit` and when verifying an abstract class, the\nfunction must be abstract.\n\n```kotlin\nimport com.anthonycr.mockingbird.core.Verify\nimport com.anthonycr.mockingbird.core.fake\nimport com.anthonycr.mockingbird.core.verify\n\ninterface Analytics {\n    fun trackEvent(event: String)\n\n    fun trackError(exception: Exception)\n}\n\nclass ClassToTest(private val analytics: Analytics) {\n    fun doSomething() {\n        analytics.trackEvent(\"doSomething was called!\")\n    }\n\n    fun doSomethingElse() {\n        analytics.trackError(RuntimeException(\"Something went wrong\"))\n    }\n}\n\nclass ClassToTestTest {\n\n    val analytics: Analytics = fake()\n\n    @Test\n    fun `analytics event for doSomething was triggered`() {\n        val classToTest = ClassToTest(analytics)\n\n        classToTest.doSomething()\n\n        verify(analytics) {\n            analytics.trackEvent(\"doSomething was called!\")\n        }\n    }\n\n    @Test\n    fun `analytics error for doSomethingElse was triggered`() {\n        val classToTest = ClassToTest(analytics)\n\n        classToTest.doSomethingElse()\n\n        verify(analytics) {\n            analytics.trackError(sameAs { e -\u003e e.message == \"Something went wrong\") })\n        }\n    }\n}\n```\n\nThere are 3 `verify*` functions.\n1. `verify`: This function accepts all the parameters that you wish to verify, performs the\n    verifications, and finally asserts that there are no unverified invocations.\n2. `verifyPartial`: This function behaves similarly to `verify`, except that it does not assert that\n    there are no unverified invocations at the end.\n3. `verifyComplete`: This function verifies that there are no unverified invocations left. This is\n    useful if you want to verify that no functions were called, or if you are using `verifyPartial`\n    and want to assert that one of the subjects being verified is actually fully verified.\n\nThere are 2 matcher functions that can be used to match parameters outside of basic equality.\n1. `sameAs`: Asserts that the value passed in matches using the lambda matcher.\n2. `any`: Accepts any parameter, useful for dynamic values or values that you really don't care\n   about asserting in your test.\n\n## Benchmark\nRun `./benchmark.sh` to execute a benchmark comparison of Mockingbird to Mockk. There are two Mockk\nbenchmarks. The first, `mockk-interface` just mocks an interface. The second, `mockk-static` uses a\nstatic mock to simulate the worst case scenario for mockk, since static mocks are the most expensive\nmocks to run. The benchmark code generates the tests according to the input parameters and then runs\nthe tests, recording the time it takes to generate the tests, compile the tests, and run the tests.\n\nSee the README files for each benchmark ([mockingbird](benchmark/mockingbird/README.md),\n[mockk-interface](benchmark/mockk-interface/README.md),\n[mockk-static](benchmark/mockk-static/README.md)) for more information about the performance\ncharacteristics of each approach.\n\n### Current benchmark runtimes (3 July 2025)\n\n#### Parameters\n- 3 classes to be verified\n- 500 tests\n- Apple M4 Pro\n\n#### Results\n- Mockingbird: 10.1 seconds\n- Mockk (Interface): 40.8 seconds\n- Mockk (Static): 82.0 seconds\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonycr%2Fmockingbird","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonycr%2Fmockingbird","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonycr%2Fmockingbird/lists"}