A tasty mocking framework for unit tests in Swift 5.0, inspired by Mockito, with a clean and simple API.
Mockit is a mocking framework for Swift that helps developers write unit tests by creating mock objects to simulate dependencies. It solves the problem of isolating code under test from its collaborators, allowing for focused and reliable test suites. Inspired by Mockito, it offers a familiar API with features like stubbing, verification, and argument capture tailored for Swift's type system.
Swift developers, particularly those building iOS, macOS, or server-side applications who need to write unit tests with mocked dependencies. It's ideal for teams practicing test-driven development (TDD) or looking to improve test coverage and maintainability.
Developers choose Mockit for its clean, readable API that reduces boilerplate and its inspiration from Mockito, which many find intuitive. Its support for multiple verification modes and helpful error messages makes debugging tests easier, while custom type matchers provide flexibility for complex scenarios.
A simple mocking framework for Swift, inspired by the famous http://mockito.org/
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Inspired by Mockito, it provides a fluent syntax for stubbing and verification, making tests intuitive and easy to write, as shown in the example code snippets.
Supports eight verification modes like Once, Never, and Times, allowing precise validation of method call frequencies and sequences in tests.
Delivers readable error descriptions when verifications fail, aiding in debugging by clearly indicating what went wrong, as mentioned in the features list.
Enables chaining of actions like thenReturn, thenDo, and thenAnswer for defining complex mock behaviors, as demonstrated in the syntax examples.
Requires creating a subclass for each mock that extends Mock and implements call forwarding, adding significant upfront development time, as admitted in the Limitations section.
Only supports primitive types by default; custom types necessitate implementing TypeMatcher protocols due to Swift's lack of reflection, which can be cumbersome.
Described as 'at an early stage' with incomplete documentation and potential instability, making it riskier for production-critical projects.
Mockit is an open-source alternative to the following products: