Press ESC to close

Chatter Apex Test Case Bug in API version 24

I noticed this issue while writing an Apex test case for some chatter related functionality. For sake of this post, I am just posting the simplified test case. Here is the code

public static testmethod void testFeeds() {
    // Create a Test Account
    Account acc = new Account(Name = 'Demo Account');
    insert acc;
    // Create FeedItem using this Account as a Parent Record
    FeedItem fp = new FeedItem();
    fp.Body = 'Testing via Apex';
    fp.parentId =;
    insert fp;
    // Query AccountFeed back to verify if the post was created correctly
    AccountFeed[] accFeed = [Select Id, Body From AccountFeed Where ParentId =:acc.Id];
    // should be 1 record in the feed for this accountid
    System.assertEquals(1, accFeed.size());

This test case fails, because there are no rows in AccountFeed for the given “parentId”. This happens only if Apex class API version is “24”, but the same tests passes if the API version is lowered, for ex. “23”.

Seems something is broken in Apex Test fixture, posted the same on discussion boards here for resolution.


After tweeting this issue @andyboettcher replied by a solution.


Thanks to Mr. Andy for suggesting the “SeeALLData” fix, this for sure fixes the problem in v24, but we loose the data isolation. I fixed original client requirement, by moving back to v23 and setting “SeeAllData=false”.

Leave a Reply

%d bloggers like this: