2017-06-15 108 views
0

測試功能,這是我的代碼如何寫銷售人員ConnectApi.FeedElement

public class ChatterFunction{ 

public ChatterFunction(){ 
    LIST<ISSUE__C> issID = [SELECT Id, Name FROM ISSUE__C]; 
    for(ISSUE__C i : issID){ 
     postfeed(i.Id); 
    } 
} 

public static void postfeed(String iss){ 
     ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput(); 
     ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput(); 
     ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput(); 
     ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput(); 

     messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>(); 


     mentionSegmentInput.id = '00528045147FTed'; 
     messageBodyInput.messageSegments.add(mentionSegmentInput); 

     textSegmentInput.text = 'Something'; 
     messageBodyInput.messageSegments.add(textSegmentInput); 

     feedItemInput.body = messageBodyInput; 
     feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem; 

     feedItemInput.subjectId = iss; 

     ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(null,feedItemInput); 
} 

}

,我試着用代碼

@IsTest(SeeAllData=true) public static void testpostfeed() { 
System.assertEquals(postfeed('a000l0013315hgr'),null); 
} 

,以測試它,但它顯示了錯誤消息:方法不存在或不正確的簽名:postfeed(字符串)

我不知道爲什麼我t不與存在....

回答

0

你的方法是靜態的,所以你需要調用它

System.assertEquals(ChatterFunction.postfeed('...'), null);