-
Notifications
You must be signed in to change notification settings - Fork 214
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
Removing some clutter from ApexMocks syntax #70
Comments
Great work - really appreciate the summary and your reasoning. I agree with almost everything above. I love the improved encapsulation and reduced clutter. A few follow up points...
The
I believe this prevents us from incrementing the call count, capturing arguments, throwing exceptions or invoking answers in the test setup phase. If we can still achieve all of these without explicit startStubbing and stopStubbing calls, I'm happy.
It's a core philosophical decision to be as close to Mockito as possible, to lower the barrier to entry and allow us to port Mockito features following their syntax. This might prove contentious but I'm ok with this in theory. @agarciaodeian - any thoughts? |
yes I understand this and would not remove the prefix. Using the single wrapper class just gives projects the option to rename fflib_Mock to something else.
That might be true. However, all your unit-tests where still running fine after my code change. Only the case where a method was mocked to throw an exception and then mocked a second time did no longer work, since the second invocation threw an exception. Thanks for your reply. Do let me know if you are interested in parts of the change, then I will create a pull request with the polished code. I believe all changes could be added without causing any breaking changes. |
Since I did not hear from @dfruddffdc and @agarciaodeian again I guess this is not something you want to follow right now. So I will just fork the project, which makes a lot of sense anyway. Most of the code-generation stuff seems deprecated and in a fork I can simply remove it 😇 |
Hey guys,
I recently started working with apex-mocks and I love it. The only thing I didn't like and where it falls a bit short with regards to Mockito is the amount of clutter in the code. Some is due to the Salesforce restrictions (no generics...) but some seemed unnecessary.
So I played arround with it a bit and found three changes that improve this. The results can be seen here: https://github.com/mischkes/fflib-apex-mocks/tree/feature/poc-for-less-clutter#a-more-complicated-case
We are already using this code in production, but it is not yet library-grade. If you are interested I would be happy to improve the code and make some pull requests.
The changes are:
Create a Utility class that encapsulates ApexMocks and Match
Make start/stopStubbing unnecessary
Record call history inside methods
All in all these changes remove approx. 50% of the necessary mocking code, which I think is really a lot.
The text was updated successfully, but these errors were encountered: