Just back from Dreamforce ’13, which was, what’s Marc’s word for it?… oh, yes… awesome.
As per my last post, I had two sessions in the DevZone this year: Practical Introduction to Chatter Publisher Actions (with Carolina Ruiz @CarolEnLaNube), and Tests and Testability: Apex Structure and Strategy
The slides for these sessions are available to download as PDF:
DF13ChatterPublisherActionsAndSalesforce1
The session recordings are also now available:
Tests and Testability – youtube
Chatter Publisher Actions and Salesforce1 – youtube
I am planning a number of posts on Tests and Testability, in which I will reuse and expand on the DF13 material.
I just wanted to say how much I appreciated your Tests and Testability presentation. Unfortunately I wasn’t able to make it to Dreamforce, but have just watched your talk on youtube. Having come from a language where using dependency injection and mocking libraries is very common, I have struggled in the Apex world to achieve this. Since I tend to abstract via Interfaces, I have tried to achieve injection of dependencies, but have had to resort to public property injection (programmatically), however I really like your approach of using @testVisible constructor and can’t wait to try it out. Great presentation; theory backed up by concrete examples.
LikeLike
Thank you so much for taking the time to give your feedback; I’m glad that you found the recording useful! As I mentioned in my post, I will be working through the material for this session in more detail on this site in the coming weeks.
LikeLike
Thanks for the explanation of fabrication, now if I create an account/contact graph in memory thus…
Account a = new Account(Id = utils…., Name=’MyCo’);
Contact c1 = new Contact (Id = utils…, Account=a, Name=’Jeff’);
Contact c2 = new Contact (Id = utils…, Account=a, Name=’Doug’);
for (Contact con : a.Contacts)
{
system.debug(con.Name);
}
system.debug(c1.Account.Name);
system.debug(c2.Account.Name);
…nothing is output from the for loop but there is output from the last two lines. It appears the relationship construction is only created one-way not both. Is there a way of constructing the objects so the for loop has some output?
LikeLike
@Colin, as you have found, the relationship is created one-way. Think of the SObjects as simple data structures with no behaviour – so the reverse relationship would not be created for you. For this fabrication to work you would also need to assign a List<Contact> to the Account SObject, but unfortunately assigning a related list like that is not supported.
So, simple fabrication of sub-selects isn’t possible; you’d need to use a different approach. Though it has been a long time coming, I am still planning to unpack my DF13 session in this blog, so look out for that.
In the meantime you might also be interested in the superb ApexMocks from @comic96
LikeLike
YouTube video is private?!!
LikeLike
It appears so 😦
Sorry, it looks like Salesforce has taken down these older recordings
LikeLike