jonreid / jonreid/ViewControllerPresentationSpy

Parallel usage of AlertVerifier and PresentationVerifier

Open
#22 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
151
Forks
17
PR merge metrics
No merged PRs in 30d

Description

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:
https://github.com/dudek-j/ViewControllerPresentationSpy/commit/feef4d951148b57be5dba3d61d66aa5312b12a29

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the AlertVerifier and PresentationVerifier behavior described in the issue, then inspect the linked fork commit to understand how shared mock ownership is changed. Verify the interaction where an alert action presents a controller, including the stated change to UIAlertController notifications; done means both verifiers can operate in one test without breaking existing presentation verification.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile-dev, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.