You need to sign in to do that
Don't have an account?
iperez_genius
another test coverage question
firstly let me say there needs to be a tutorial section to explain how to do all the things necessary to create a trigger and deploy it with all term explained....
secondly i have created my trigger, which is tested and works 100% in my developer license.
I am trying to bring it into my production environment.
I have downloaded eclipse installed the plugin, and saved my trigger to saleforce, production...
the trigger is inactive though. From what i have read inorder to activate the trigger i need to get my test coverage greater than 75%.
apparently to do this i need to create a test class.
Briefly my trigger, on insertion of a task with subject mail_merged a custom field in a lead is set from no to yes.
Below is my attempt at a test class
here is my trigger
what must i do next to get test coverage great than 75%
Please help...
thanks in advance
Ilan
secondly i have created my trigger, which is tested and works 100% in my developer license.
I am trying to bring it into my production environment.
I have downloaded eclipse installed the plugin, and saved my trigger to saleforce, production...
the trigger is inactive though. From what i have read inorder to activate the trigger i need to get my test coverage greater than 75%.
apparently to do this i need to create a test class.
Briefly my trigger, on insertion of a task with subject mail_merged a custom field in a lead is set from no to yes.
Below is my attempt at a test class
Code:
public class updateLead { static testMethod void testUpdateLead() { Task t1 = new Task (subject='Mail merge document(s) generated: mail_Merged'); Task t2 = new Task (subject='Email'); Task[] myTasks = new Task[]{t1,t2}; insert myTasks; Task queryTask1 = [select Id,subject from Task where Id = :t1.Id]; system.assertEquals('Mail merge document(s) generated: mail_Merged',queryTask1.subject); Task queryTask2 = [select Id,subject from Task where Id = :t2.Id]; system.assertEquals('Email',queryTask2.subject); } }
here is my trigger
Code:
trigger updateLead on Task (after insert) { Lead[] leadsToUpdate;for (Task t: Trigger.new) { String accountid = t.whoId; leadsToUpdate = [select id, SentPack__c, email from lead where id =: accountid]; String Otype = accountid.substring(0, 3); if (Otype=='00Q' && t.Subject=='Mail merge document(s) generated: mail_Merged') { for (Lead ltu : leadsToUpdate) { if (ltu.SentPack__c == 'no') { ltu.SentPack__c = 'yes' ; update ltu; } } } } }
what must i do next to get test coverage great than 75%
Please help...
thanks in advance
Ilan
I have created my sandbox and tested my trigger...and it works fine
I have uploaed the test class that is written above and it has a test coverage of 100%
I am not sure what to do now...
How do i activate the trigger in the production interface?
Ilan
when i run the class in the sandbox i get a test coverage of 50%...
is someone able to help me with my test class
Ilan
here is my new tst unit class
I have debug statement throughout the class and the trigger and i know that the class enters the trigger... the task gets created but at line 7
the trigger ends with
And for the life of me i am not sure why this is the case.
can someone help?
Ilan
Also, please note that your code is not bulk-safe. You are retrieving leadsToUpdate once for every incoming record, and possibly calling Update for each Lead record too. An alternative strategy would be to try retrieving all leads in one call and updating all records in one call (for examples, see the Force.com Cookbook or other Forum discussions on Triggers).
my test class works fine...my trigger works fine...however....
the new and latest issue in the trigger saga...which has been going on for 3 weeks is
so the trigger activates and correctly modifies the data but when the last command of "update the lead" the data is not saved...
and therefore after the trigger has finished and we return to the test class and assert that a specific value has changed the response is negative.
I am not sure why this is...
my new and improved code is below
The Class
the trigger
i have a coverage of 100% and a success stamp on my trigger...
i now am trying to work out how to activate my trigger in the production interface
i have updated my files in eclipse,
and i get a coverage of 54%,
not only that the trigger compiles fine, that is no errors, but the class has a ! mark with an error stating file is not saved on server.
so i really dont know how to get this working...
can someone help me please?
Ilan
I am trying to sync it with the server but all i can do is sync it with the sandbox...
i run the test in the sandbox and i get hte coverage of 100%
i have no idea how to get the class saved onto the porduction ui
I am about to break something :)
this should be an easy exercise, instead its bladdy impossible grrr....
No idea how to sync it...i have of course tried deploy, save to server, sync to server...nothing seems to change the class on the production server
please help
ilan