function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Varun99Varun99 

Test coverage

Hi,

 

 

How to write test coverage for static methods how to pass parentid and body? Can any one help?

 

public class Helper_Chatter {

public static void notifyAdmin(String text){
User u = [select id from User limit 1];
FeedItem post = new FeedItem();
post.ParentId = u.Id;
post.Body = text;
insert post;
}

public static void notifyUser(Id userId, String text){
FeedItem post = new FeedItem();
post.ParentId = userId;
post.Body = text;
insert post;
}

public static FeedItem createPost(Id id, String text){
FeedItem post = new FeedItem();
post.ParentId = id;
post.Body = text;
return post;
}

static testMethod void testNotify()
{

Id id = [select id from user limit 1].id;
Helper_Chatter.notifyAdmin('test');
Helper_Chatter.notifyUser(id,'test');
Helper_Chatter.createPost(id,'test');
FeedItem p = new FeedItem();
p.ParentId = Id;
p.Body = 'text';
insert p;
}

}

 

Thank you

Varun99Varun99

Hi,

 

Thanks for your reply. It will help my requiremrnt.

 

 

Thank you.