Skip to content

Parallel usage of AlertVerifier and PresentationVerifier #22

Description

@dudek-j

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions