Mockingbird v0.14.0 Release Notes

Release Date: 2020-07-15 // almost 2 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:

    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