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

[QUESTION] Thread-Safe Mocks #1275

Open
pklapuch opened this issue Feb 19, 2024 · 1 comment
Open

[QUESTION] Thread-Safe Mocks #1275

pklapuch opened this issue Feb 19, 2024 · 1 comment

Comments

@pklapuch
Copy link

Hi,

Did anyone consider threading issues? Would it be hard to generate serialized access to Mock properties?
I guess Mock could either be generated as actor or it could wrap it's properties using queue.sync { }.

This especially becomes a problem with arrays (i.e. the ...invocations) which leads to EXT_BAD_ACCESS but can have undefined behavior with just about any read/write property.. which leads to inconsistent state at the end of the test.

(I guess most tests are simple and run in isolated/serialized context, but now and then we have features that support concurrent execution and that becomes a problem).

In these cases I either end up creating custom Mocks or I extend generated mock, override methods and wrap them with queue.sync etc...

Any suggestions would be welcome :)
Thanks!

@krzysztofzablocki
Copy link
Owner

hey, many companies just take the default macro we bundle and tweak them so there really isn't much stopping you from doing so, if you do then you could add a variant of the template as a pr 😉

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

No branches or pull requests

2 participants