07 Jan 2023
Adds @MainActor annotations to spies for Xcode 14 fix. You will need to add @MainActor to any test suites that use these spies.
06 Aug 2022
Now available from Swift Package Manager!
06 Nov 2021
- Added tvOS support.
- Packaged pre-built binary as single XCFramework containing 5 architectures:
- Mac Catalyst
- iOS device
- iOS simulator
- tvOS device
- tvOS simulator
- Fixed Xcode 12.5 build errors. Thanks to: Felix Yuan
07 Oct 2020
- Bump project settings to Xcode 12.
- Bump minimum deployment target to iOS 10.0.
21 Aug 2020
Fixed to load on iOS 10.3.3 devices.
30 Jan 2020
This release adds diagnostic test failures if verifiers clash.
- Fail test if code creates multiple instances of any single verifier. This inadvertently undid its swizzling, leading to test failures that were tricky to diagnose. Now a failure message provides guidance.
- Also fail if an AlertVerifier and a PresentationVerifier exist simultaneously, since they both swizzle UIAlertViewController. This has the potential to change test results, so this is marked as a major release.
13 Sep 2019
Switch to Legacy Build System to try to improve flaky build errors around importing Swift-generated headers into Objective-C.
05 Sep 2019
Reduced minimum deployment target to iOS 9.0.
30 Aug 2019
Added DismissalVerifier
to capture calls to dismiss view controller. The Swift version has a
verify
method which checks:
- That the dismissed count is 1.
- The animated flag.
- The dismissed view controller, if provided.
Like the other verifiers, it also has a capturedCompletion
to capture any production code
completion handler, and a testCompletion
so that test code can supply its own completion handler.
24 Aug 2019
- Fix alert
verify
to pass call site file/line for title and message errors.
23 Aug 2019
Added verify
methods to the Swift versions of each verifier.
- The
PresentationVerifier
method checks:- That the presented count is 1.
- The animated flag.
- The presenting view controller, if provided.
- The type of the presented view controller.
- Returns the view controller cast to the expected type (or
nil
if it didn't match).
- The
AlertVerifier
method checks:- That the presented count is 1.
- The title.
- The message.
- The animated flag.
- The preferred style (
.alert
or.actionSheet
). - The presenting view controller, if provided.
- The titles and styles of each action.
24 Jul 2019
MockUIAlertController is dead. Long live ViewControllerPresentationSpy!
- Added
PresentationVerifier
to capture any presented view controller. It's able to capture segues. - Rewrote alert verifier in Swift. You no longer need a bridging header.
- Simplified name of alert verifier to
AlertVerifier
(Swift) orQCOAlertVerifier
(Objective-C). - Use simpler naming for invoking button action, and made it a Swift throwing function. This changes the Objective-C implementation to return an NSError via an "in-out" parameter.
- Renamed test code completion handler to
testCompletion
. - The production code completion handler passed to
present(_:animated:completion:)
is no longer executed right away. Instead, it's captured incapturedCompletion
. That way tests can execute it after executing a button action. - Removed
actionTitles
and-styleForButtonWithTitle:
, deprecated in Version 3.1.0.
10 Feb 2019
- Added
completion
closure invoked when alert is presented. If you present an alert fromDispatchQueue.main.async
, you can use this to fulfill an XCTestExpectation for async testing. - Improved README instructions on bridging header for Swift.
01 Jan 2019
- Added
actions
which greatly simplify Swift tests. Instead ofalertVerifier.actionsTitles[0] as? String
, usealertVerifier.actions[0].title
- Added
preferredAction
- Added
textFields
- Share scheme for Carthage builds. Thanks to: Kevin Donnelly
Deprecated:
- Deprecated
actionTitles
and-styleForButtonWithTitle:
. Useactions
instead.
02 Feb 2018
- Changed
animated
from NSNumber to BOOL. - Added
presentingViewController
30 Jan 2018
- Fixed crash when presenting UIDocumentMenuViewController while mocking UIAlertController. Thanks to: Andrei Tulai
06 Mar 2017
- Fixed nullability mistake: actionTitles are non-null.
- Add shared scheme to satisfy latest version of Carthage.
19 Feb 2017
- Annotate nullability. The QCOMockAlertVerifier initializer is now non-null, which changes Swift use.
- Added Swift sample app.
- Updated example tests to put QCOMockAlertVerifier in test fixture. This is now recommended, to avoid tests which accidentally present real alerts.
11 Sep 2016
- Change UIAlertController's actual
preferredStyle
instead of keeping it in an associated property, to avoid UIKit consistency exceptions. Thanks to: nirgin - Allow
executeActionForButtonWithTitle:
even when no handler was set. Thanks to: John Foulkes - Don't record presentation of non-alerts. Thanks to: Tom Bates
- Quiet runtime warning about attempting to load view controller while deallocating. Thanks to: Marcelo Fabri
24 Dec 2015
- Repackage as Cocoa Touch Framework project.
- Support Carthage.
- CocoaPods: Distinguish between public headers and private headers.
23 Aug 2015
- Initial release. Thanks to Victor Ilyukevich for suggestions, testing, and cleanup.