I have test method where i try to get the Feeditem of type trackedChange which is automatically created when we update a field value that is being tracked via feedTracking. But the test method is not able to get that feedItem record. Even tried with lowering the version, but no results. Can someone help?
Hi,
use the isTest(SeeAllData=true) annotation to grant test classes access to all data in the organization
@isTest(SeeAllData=true)
public class TestDataAccessClass {
static testmethod void mytest(){
Account acc = new Account(Name = 'TestAccountBhushan',Phone = '040-754-7845');
insert acc;
acc.Phone = '040-123-4567';
update acc;
List<FeedItem > txtFeedItem = [SELECT Id,
ParentId FROM FeedItem Where ParentId=: acc.Id];
System.assertEquals(1, txtFeedItem.size());
}
}
Please let me know if the issue persist.if this post helps you the please give kudos(click on star at left) and mark it as a solution.
I have tried with this, sitll it fails.
Hi,
Please post me your trigger where the feed item is automatically created when account record is updated.
You need to update those fields of account for which you Enable Feed Tracking.
i.e. if you enable feed tracking for phone field only then it creates feedItem record.
Thanks,
Bhushan
It means Feed tracking is not working in test class because " Test methods does not actually commit data,so Feed Change records is not created."
Please visit
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_unit_tests.htm
Thanks for help!