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

MockFunction and Mock macros #43

Merged
merged 4 commits into from
Feb 6, 2025
Merged

MockFunction and Mock macros #43

merged 4 commits into from
Feb 6, 2025

Conversation

swift-student
Copy link
Contributor

Adds a @Mock macro enabled by a _MockFunction macro that adds bodies to functions. This allows for easily declaring a mock type within a test target and doesn't require an #if DEBUG wrapper like @AddMock does. The simplest way to use this macro is to declare a struct or class that adopts a protocol and use the fixit to generate the members:

Screen Recording 2025-01-24 at 3 06 47 PM

I used the _MockFunction macro for the @AddMock macro as well, and did some test cleanup.

@swift-student swift-student force-pushed the sg/mock_function branch 4 times, most recently from 56922f5 to ee983e9 Compare January 27, 2025 23:14
@swift-student
Copy link
Contributor Author

Using this PR to fix/test things as I integrate with our app. Will clean up and separate into PRs before marking as ready for review.

@swift-student swift-student force-pushed the sg/mock_function branch 2 times, most recently from 3ecfe3a to e96d8a0 Compare January 30, 2025 21:35
@swift-student swift-student marked this pull request as ready for review January 30, 2025 21:42
@swift-student swift-student requested a review from a team as a code owner January 30, 2025 21:42
@swift-student
Copy link
Contributor Author

Tested this by replacing uses of Spy in our app's test target, seems to work well.

@swift-student swift-student merged commit bd20341 into main Feb 6, 2025
2 checks passed
@swift-student swift-student deleted the sg/mock_function branch February 6, 2025 15:42
@swift-student
Copy link
Contributor Author

This resolves #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants