I wasted an entire week just picking the music for that intro, woulda launched my channel two months earlier but I spent a lot of time designing and building that intro lol
Nice work! Thank you for sharing it! Quick question, how do we actually cover the Selector layer since it is all mocked? hm I mean, we dont actually test other classes than the one we are working on, so how to get the selector layer covered and tested? Should we create regular test class for the selector layer?
Good question! Sorry it took me so long to respond, but yes you should just create regular integration tests for selector layer classes, no need to create unit tests or do any mocking for them.
Can you "install" this library just by copying its corresponding files? I'm using an .sh file to generate scratch orgs and it's really annoying to deploy the package every time I create a new one, and also I want to keep libraries tracking within my repo. Thanks a lot for this series btw, It was amazingly helpful!
Yep you can, just copy the files from the Apex Mocks repo and you're good to go! All the files you need are located here: github.com/apex-enterprise-patterns/fflib-apex-mocks/tree/master/sfdx-source/apex-mocks
You can mock metadata as long as you create a selector class for the metadata, which I would personally suggest doing. That said, queries for metadata are lightning fast compared to queries for regular data so you don’t gain as much benefit speed wise in testing.
Kind of yes and kind of no. This is maybe too complicated a topic for a comment. I will try to produce something to explain it a bit in the near future. Basically you have to use an interface in your selectors to dynamically change your query on an object by object basis. So it's not dynamic soql in the literal sense, but it does allow you to dynamically generate queries based on the incoming object/situation.