A boilerplate-free mocking framework for Swift with a Mockito-like DSL, using compile-time code generation.
Cuckoo is a mocking framework for Swift that generates mock objects at compile time to facilitate unit testing. It solves the problem of Swift's lack of runtime reflection by automatically creating mock implementations for classes and protocols, allowing developers to stub behaviors and verify interactions without writing boilerplate code.
Swift developers building iOS, macOS, tvOS, or watchOS applications who need a robust mocking solution for unit testing their code, especially those familiar with Mockito from Java/Android backgrounds.
Developers choose Cuckoo because it provides a familiar Mockito-like API, supports complex Swift features like generics and inheritance, and eliminates manual mock implementation through its code generator, making tests cleaner and more maintainable.
Boilerplate-free mocking framework for Swift!
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses a syntax similar to Mockito, reducing the learning curve for developers with Java/Android backgrounds, as highlighted in the introduction.
Overcomes Swift's lack of reflection by generating mock support structures automatically, ensuring type-safe and efficient mocks without runtime overhead.
Handles inheritance, generics, and type inference, allowing mocking of sophisticated Swift code that many other frameworks struggle with.
Wraps OCMock to mock Objective-C classes and protocols within Swift tests, making it viable for mixed codebases, as detailed in the README.
Explicitly cannot mock structs, final classes, private members, or static methods, forcing workarounds like protocol adoption and limiting its use in modern Swift codebases.
Requires adding run script build phases, configuring Cuckoofile.toml, and managing generated files, which adds initial overhead and potential integration issues, especially in Xcode 15 with sandboxing.
Relies on the Cuckoonator tool, which can increase build times, fail due to GitHub API limits, or require manual troubleshooting, as noted in the installation warnings.