You need to sign in to do that
Don't have an account?
Best way to test that a chatter post has been posted to the news feed?
Currently I have a trigger attached to when a new document is uploaded (after insert) in a custom document repository that I have created. When it is inserted, a new feed item is created and posted to the news feed as a linkpost item.
I was just wondering what would be the most efficent way of testing that this event has occured?
I've currently created a test class, created a 'test document' and inserted it to activate the trigger. I've then created a List<NewsFeed> newsfeed selecting the news feed. Then using System.assertEquals to compare the Title of the item on the top of the newsfeed to that of the test document I created.
Is this the best way to test this?
I have encountered one problem doing this where the code executes too fast btween inserting the document and then getting the list so the System.assertEquals fails. To get round this I put in a while loop to waste a bit of time which seems to work now.
I was just wondering if anyone has any tips on creating tests for triggers that post chatter posts?
Any chance you could post the method you used to wait until items showed up in the news feed? I'm having the same issue.