/mockingbird

A Swifty mocking framework for Swift and Objective-C.

Primary LanguageSwiftMIT LicenseMIT

Mockingbird - Swift Mocking Framework

Mockingbird

Package managers MIT licensed #mockingbird Slack channel

Mockingbird makes it easy to mock, stub, and verify objects in Swift unit tests. You can test both Swift and Objective-C without writing any boilerplate or modifying production code.

Documentation

Visit MockingbirdSwift.com for quick start guides, walkthroughs, and API reference articles.

Getting Started

  1. Add Mockingbird as a dependency using your favorite dependency manager
  2. Look for mockingbird shell script in the dependency files
  3. Drag & drop the shell script into the terminal
  4. With the shell path written in the terminal, add the following configure {Test Target} -- --target {Main Target}
Hint
/path/to/mockingbird configure MockingbirdWalkthroughTests -- --target MockingbirdWalkthrough
  1. Get back to Xcode
  2. Hit ⇧⌘U
  3. Now you're ready to start using the framework

Still struggling? Check out this video then.

Examples

Automatically generating mocks.

$ mockingbird configure BirdTests -- --target Bird

Manually generating mocks.

$ mockingbird generate --testbundle BirdTests --target Bird --output Mocks.generated.swift

Using Mockingbird in tests.

// Mocking
let bird = mock(Bird.self)

// Stubbing
given(bird.canFly).willReturn(true)

// Verification
verify(bird.fly()).wasCalled()

Contributing

Please read the contributing guide to learn about reporting bugs, developing features, and submitting code changes.

License

Mockingbird is MIT licensed. By contributing to Mockingbird, you agree that your contributions will be licensed under its MIT license.