@isTest private class CheckChatterPostsTest { @isTest static void testError() { FeedItem f = new FeedItem( Type = 'TextPost', ParentId = Userinfo.getUserId(), Body = 'Text' ); Database.SaveResult[] lsr = Database.insert(new FeedItem[] {f}, false); for (Integer sIdx = 0; sIdx < lsr.size(); sIdx++) { Database.SaveResult sr = lsr[sIdx]; System.assertEquals(false, sr.isSuccess()); System.assertEquals(System.Label.Error_ChatterPostToMyFollowers, sr.getErrors()[0].getMessage()); } } }