{"id":13995169,"url":"https://github.com/danielsaidi/MockingKit","last_synced_at":"2025-07-22T21:32:15.863Z","repository":{"id":37934172,"uuid":"181319724","full_name":"danielsaidi/MockingKit","owner":"danielsaidi","description":"MockingKit is a Swift SDK that lets you easily mock protocols and classes in `Swift`.","archived":false,"fork":false,"pushed_at":"2024-03-10T09:20:40.000Z","size":4729,"stargazers_count":82,"open_issues_count":3,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-18T11:22:00.892Z","etag":null,"topics":["ios","macos","mock","mocking","swift","tdd","tvos","unit-test","unit-testing","visionos","watchos"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/danielsaidi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["danielsaidi"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2019-04-14T14:18:09.000Z","updated_at":"2024-06-22T00:35:16.568Z","dependencies_parsed_at":"2024-01-18T05:22:45.160Z","dependency_job_id":"e8c3b3f3-407e-434a-89bc-02e8ffb92653","html_url":"https://github.com/danielsaidi/MockingKit","commit_stats":{"total_commits":208,"total_committers":4,"mean_commits":52.0,"dds":"0.014423076923076872","last_synced_commit":"552960adffa232588d6183ad622afe0a0ae62594"},"previous_names":["danielsaidi/mocknroll","danielsaidi/mockery"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FMockingKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FMockingKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FMockingKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FMockingKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielsaidi","download_url":"https://codeload.github.com/danielsaidi/MockingKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227177797,"owners_count":17743168,"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":["ios","macos","mock","mocking","swift","tdd","tvos","unit-test","unit-testing","visionos","watchos"],"created_at":"2024-08-09T14:03:17.068Z","updated_at":"2025-07-22T21:32:15.845Z","avatar_url":"https://github.com/danielsaidi.png","language":"Swift","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Resources/Icon.png\" alt=\"Project Icon\" width=\"250\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/danielsaidi/MockingKit?color=%2300550\u0026sort=semver\" alt=\"Version\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-6.0-orange.svg\" alt=\"Swift 6.0\" /\u003e\n    \u003ca href=\"https://danielsaidi.github.io/MockingKit\"\u003e\u003cimg src=\"https://img.shields.io/badge/documentation-web-blue.svg\" alt=\"Documentation\" /\u003e\u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/danielsaidi/MockingKit\" alt=\"MIT License\" /\u003e\n    \u003ca href=\"https://github.com/sponsors/danielsaidi\"\u003e\u003cimg src=\"https://img.shields.io/badge/sponsor-GitHub-red.svg\" alt=\"Sponsor my work\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n# MockingKit\n\nMockingKit is a mocking library for Swift that lets you create mocks of any protocol or class. This can be used to mock dependencies in unit tests, and to fake not yet implemented features in your apps.  \n\nMockingKit automatically records every method call, to let you verify that your code behaves as you expect. You can also register register dynamic function results to control your test outcome.\n\nMockingKit doesn't require any setup or build scripts, and puts no restrictions on your code or architecture. Just create a mock, set up how you want to use and inspect it, and you're good to go.\n\n\n\n## Installation\n\nMockingKit can be installed with the Swift Package Manager:\n\n```\nhttps://github.com/danielsaidi/MockingKit.git\n```\n\n\n\n## Support My Work\n\nMaintaining my various [open-source tools][OpenSource] takes significant time and effort. You can [become a sponsor][Sponsors] to help me dedicate more time to creating, maintaining, and improving these projects. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed. Thank you for considering!\n\n\n\n## Getting started\n\nMockingKit lets you mock any protocol or open class. For instance, consider this simple protocol:\n\n```swift\nprotocol MyProtocol {\n\n    func doStuff(int: Int, string: String) -\u003e String\n}\n```\n\nWith MockingKit, you can easily create a mock implementation of this protocol: \n\n```swift\nimport MockingKit\n\nclass MyMock: Mock, MyProtocol {\n\n    // Define a lazy reference for each function you want to mock\n    lazy var doStuffRef = MockReference(doStuff)\n\n    // Functions must then call the reference to be recorded\n    func doStuff(int: Int, string: String) -\u003e String {\n        call(doStuffRef, args: (int, string))\n    }\n}\n```\n\nYou can now use the mock to `register` function results, `call` functions and `inspect` recorded calls.\n\n```swift\n// Create a mock instance\nlet mock = MyMock()\n\n// Register a result to be returned by doStuff\nmock.registerResult(for: mock.doStuffRef) { args in String(args.1.reversed()) }\n\n// Calling doStuff will now return the pre-registered result\nlet result = mock.doStuff(int: 42, string: \"string\") // =\u003e \"gnirts\"\n\n// You can now inspect calls made to doStuff\nlet calls = mock.calls(to: \\.doStuffRef)             // =\u003e 1 item\ncalls[0].arguments                                   // =\u003e (42, \"string\")\ncalls[0].result                                      // =\u003e \"gnirts\"\nmock.hasCalled(\\.doStuffRef)                         // =\u003e true\n```\n\nSee the online [getting started guide][Getting-Started] for more information.\n\n\n\n## Documentation\n\nThe online [documentation][Documentation] has more information, articles, code examples, etc. \n\n\n\n## Demo Application\n\nThe `Demo` folder has an app that lets you explore the library and see how its mocks behave.\n\n\n\n## Contact\n\nFeel free to reach out if you have questions or if you want to contribute in any way:\n\n* Website: [danielsaidi.com][Website]\n* E-mail: [daniel.saidi@gmail.com][Email]\n* Bluesky: [@danielsaidi@bsky.social][Bluesky]\n* Mastodon: [@danielsaidi@mastodon.social][Mastodon]\n\n\n\n## License\n\nMockingKit is available under the MIT license. See the [LICENSE][License] file for more info.\n\n\n\n[Email]: mailto:daniel.saidi@gmail.com\n[Website]: https://www.danielsaidi.com\n[GitHub]: https://www.github.com/danielsaidi\n[OpenSource]: https://danielsaidi.com/opensource\n[Sponsors]: https://github.com/sponsors/danielsaidi\n\n[Bluesky]: https://bsky.app/profile/danielsaidi.bsky.social\n[Mastodon]: https://mastodon.social/@danielsaidi\n[Twitter]: https://www.twitter.com/danielsaidi\n\n[Documentation]: https://danielsaidi.github.io/MockingKit\n[Getting-Started]: https://danielsaidi.github.io/MockingKit/documentation/mockingkit/getting-started\n[License]: https://github.com/danielsaidi/MockingKit/blob/master/LICENSE\n","funding_links":["https://github.com/sponsors/danielsaidi"],"categories":["Swift","Libraries"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsaidi%2FMockingKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielsaidi%2FMockingKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsaidi%2FMockingKit/lists"}