There are a couple of scenarios in our app where a controller is presented directly from an alert action. We’d like to use AlertVerifier to trigger the action (implicitly verifying the button title) and, within the same test, inspect the presented controller.
@Test
func `example test`() throws {
let sut = fixture()
let alert = AlertVerifier()
sut.showAlert()
let presenter = PresentationVerifier()
try alert.executeAction(forButton: "My Action")
#expect(spy.presentedViewController is MyViewController)
}
This isn’t currently possible due to the mutually exclusive ownership of the present mock between AlertVerifier and PresentationVerifier.
I’ve put together a minimal change that allows both verifiers to operate simultaneously:
dudek-j@feef4d9
Is there a reason this approach wouldn’t be suitable for upstream adoption, or would you consider supporting this workflow?
Note: The fork introduces a behavioural change where presenting a UIAlertController no longer notifies PresentationVerifier. This can be adjusted if needed.
There are a couple of scenarios in our app where a controller is presented directly from an alert action. We’d like to use AlertVerifier to trigger the action (implicitly verifying the button title) and, within the same test, inspect the presented controller.
This isn’t currently possible due to the mutually exclusive ownership of the present mock between AlertVerifier and PresentationVerifier.
I’ve put together a minimal change that allows both verifiers to operate simultaneously:
dudek-j@feef4d9
Is there a reason this approach wouldn’t be suitable for upstream adoption, or would you consider supporting this workflow?
Note: The fork introduces a behavioural change where presenting a UIAlertController no longer notifies PresentationVerifier. This can be adjusted if needed.