Mockingbird v0.14.0 Release Notes
Release Date: 2020-07-15 // almost 4 years ago-
Targets
- Xcode 11.5 / Swift 5.2
- ๐ iOS 8.0+, macOS 10.14+, tvOS 9.0+
Migrating from 0.13
๐ Thanks to Joe Tennant and various partners for testing this monthโs 0.14 release candidate. If youโd like to help with a future release or add your project to Mockingbirdโs source compatibility tests, please reach out on Slack.
Explicit Stubbing Syntax
๐ To make the framework more accessible to all users, this release introduces an explicit stubbing syntax that uses named methods instead of global operators. Although the explicit stubbing syntax will be the default in documentation going forward, the
~>
stubbing operator will continue to exist as the shorthand notation.The explicit stubbing syntax is a 1:1 match with the stubbing operator, so switching between the two notations is very intuitive.
// Explicit stubbing syntaxgiven(bird.canChirp()).willReturn(true)given(bird.canChirp()).willThrow(BirdError())given(bird.canChirp(volume: any())).will { volume inreturn volume \< 42}// Shorthand stubbing operatorgiven(bird.canChirp()) ~\> truegiven(bird.canChirp()) ~\> { throw BirdError() }given(bird.canChirp(volume: any())) ~\> { volume inreturn volume \< 42}
๐ As part of the explicit stubbing syntax addition, this release also includes an API reference generated from HeaderDoc comments: https://birdrides.github.io/mockingbird/latest/
Fast Compilation with Thunk Stubs
โ To reduce compilation time, Mockingbird now only generates mocking code (known as thunks) for types referenced in tests with
mock(SomeType.self)
. Types not used in any test files produce minimal generated code in the form of โthunk stubs,โ which are simply bodies containingfatalError
. Projects that indirectly synthesize mocked types, such as through Objective-C based dependency injection, may incorrectly encounter thunk stubs during tests and require special consideration.- Option 1: Explicitly reference each indirectly synthesized type in your tests, e.g.
_ = mock(SomeType.self)
. References can be placed anywhere in the test target sources, such as in thesetUp
method of a test case or in a single file. - Option 2: Disable thunk stubs entirely by adding the
--disable-thunk-stubs
generator flag.
๐ New Features
- โ Added explicit stubbing syntax (#138)
Andrew Chang | Sterling Hackley | Ryan Meisters - โ Added system to generate thunks dynamically from used mocks (#146)
Andrew Chang - โ Added generated documentation from HeaderDoc comments using SwiftDoc (#141)
Andrew Chang
โจ Enhancements
- ๐ Fixed regression in recording throwing invocations (#148)
Andrew Chang | Joe Tennant - ๐ Improved missing stub implementation test failure message by including invocation stack trace and examples (#142)
Andrew Chang - ๐ Fixed missing return type in ordering logic (#145)
Andrew Chang - ๐ Improved SPM installation instructions (#147)
Andrew Chang - ๐ Improved documentation for class mocks and unavailable mocks (#149)
Andrew Chang