You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a situation when I needed to have a null pattern implementation for production environment of a mockable protocol which was easily created with Mock..(policy: .relaxed). However by default all mocks are under #if MOCKING compiler flag.
Would that be possible to opt out for the MOCKING flag when generating mocks? Such that the mock can be used in release configuration.
Something like this:
@Mockable(underFlag: false)// or better namingprotocol...{}
Currently I configure MOCKING also for release config, but this makes all protocols available in release. I only needed for some protocols.
Alternative is to create the implementation for release config manually without using the Mock generated.
The text was updated successfully, but these errors were encountered:
Extending the library with more control over the compile flag is a great idea, it already crossed my mind!
That being said, I would not suggest using the generated mocks in production as a default implementation or similar. They are designed for testing and will keep track of every function call, store return values, etc..., that can result in poor performance and unexpected results when used as a "real" implementation. The main use case for the generated mocks was meant to be SwiftUI previews and unit testing. If I needed relaxed mock implementations in prod, I would create them manually.
Regardless, I will happily consider this feature request as it could help in different architectures and make the library usage more seamless.
Im thinking of letting users provide the flag as an optional string literal with a default "MOCKING" value like:
Just a thought..
I had a situation when I needed to have a null pattern implementation for production environment of a mockable protocol which was easily created with Mock..(policy: .relaxed). However by default all mocks are under #if MOCKING compiler flag.
Would that be possible to opt out for the MOCKING flag when generating mocks? Such that the mock can be used in release configuration.
Something like this:
Currently I configure MOCKING also for release config, but this makes all protocols available in release. I only needed for some protocols.
Alternative is to create the implementation for release config manually without using the Mock generated.
The text was updated successfully, but these errors were encountered: