You need to sign in to do that
Don't have an account?
please Write a test class for trigger(after update) below Code please help me
trigger EmailAlert on Task (after Update) {
for(Task m : trigger.new)
{
if (m.Mail_Send_Check__c == True ) {
//User p = [SELECT Id,Email FROM User WHERE UserRole = 'Team lead/Supervisor'];
List <User> p = [SELECT Id,Email,Name FROM User WHERE UserRoleId IN(select id from UserRole where Name = 'Team lead/Supervisor')];
Set<string> users = new Set<string>();
List<Task> taskList = new List<Task>();
for(Integer i = 0; i< p.size(); i++)
{
users.add(p[i].id);
//}
//for(string requireduser :users)
//{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(p[i].Id);
mail.setTemplateId('00XF0000001P4ll');
mail.saveAsActivity=false;
//mail.add(mail);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
//Messaging.sendEmail(mail);
Task tt = new Task();
//tt.Ownerid = P[0].id;
tt.Ownerid = p[i].id;
tt.Status = 'Not Started';
tt.ActivityDate = date.today();
tt.Subject = 'Alert Task';
taskList.add(tt);
}
insert taskList;
}
}
}
Hi,
I can give you skeleton for writing the test method and can suggest what you need to do.
First go through below links which will give you basic understanding about writing test methods.
http://teachmesalesforce.wordpress.com/2011/05/07/how-to-write-a-trigger-test/
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_test.htm
I didn't check the above code in my org, it may contain some syntax error or need to update some test data.
Try to write the more test data if required with the information provided above.
thank's for giving solution
but
it will Came Code coverage 0%(Zero) yar.
can u please check it your organization
it's very important
thanks Hari
for giving Good Suggestion
Now I got it.