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 containing fatalError. 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 the setUp 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

    โœจ 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