You need to sign in to do that
Don't have an account?

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
Hi
follow the links to create a User in testMethod
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_tools_runas.htm
http://developer.force.com/cookbook/recipe/using-system-runas-in-test-methods
Hi,
Thanks for your reply. It will help my requiremrnt.
Thank you.