Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to verify that an async function eventually sends an NSNotification. #1013

Open
younata opened this issue Nov 3, 2022 · 0 comments
Open
Labels

Comments

@younata
Copy link
Member

younata commented Nov 3, 2022

The following test does not work:

func asyncFunctionPostingNotification() async {
    // ...
    NotificationCenter.default.post(...)
}

expect { await asyncFunctionPostingNotification() }.to(postNotification(...))

Because of how async expectations are implemented, the Expression (await asyncFunctionPostingNotification() } is called before the matcher (postNotification(...)) is called. This is a result of the approach we take with async expressions, where the expression is evaluated, then the result of the expression is passed into the matcher.

Perhaps we should take this as a chance to rethink how AsyncExpectation works, and provide full end-to-end support for async expressions. We could use something approaching the current method as a fallback for existing, non-async matchers.

@younata younata added the bug label Nov 3, 2022
@younata younata added this to the v12.0.0 milestone Nov 3, 2022
@younata younata removed this from the v12.0.0 milestone Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant