+ Start a Discussion

Cannot get test coveragage to increase 2 issues

1) I have a trigger that works in sb and does exactly what I want it to do:

Class I wrote will not get it above 55% (when it passed)

2) Made a small change and now it does not pass, but not seeing what is wrong.

I know - should have made a backup before changing!



Forgot to post the code - one of those Mondays, and, the test was based on a post I saw; looks like it overdoes it, but I am new at this.



Trigger Pharmacy_Demo_Completed on Task (before insert){
   for (Task T : trigger.new){
      string TaskProfile = 'Implementation Director';
      string TaskSubject = t.subject;
      string TaskType = 'Send Contracts';
      if (TaskSubject == 'Pharmacy Demo Completed'){
          List <User> usr = [select Id from User where Profile.Name =:TaskProfile limit 1];
 //         system.debug (Usr.size());

//          If (Usr.size() < 1){
//            system.debug ('No entries found for ');}
//          if (usr.size() > 0)
                {User u = [select Id ,name from User where Profile.Name =:TaskProfile limit 1];
                t.ownerid = u.id;
                t.type = TaskType;}


public class Taskusertest2 {
    List<Task> insertedTasks = new List<Task>{};
    static testMethod void myUnitTest() {
    for(Integer i = 0; i < 100; i++)    
        {Task t = new Task();
            t.IsRecurrence = FALSE;
            t.sma__CreatedLocationVerified__c = FALSE;
            t.IsReminderSet = FALSE;
            t.MA_Clean_State__c = 'tx';
            t.Subject = 'Testing';
            t.Type = 'Research';
            t.Priority = 'Normal';
            t.Description = 'Task Class Test';
            t.Status = 'Completed';
        insert t;}
         List<Task> insertedTasks = [SELECT Description
                                                FROM Task
                                                WHERE Status = 'Completed'];
         {for(Task t : insertedTasks)
          'This Task is probably left over from testing. It should probably be deleted.',
//        System.assertNotEquals(t.id, null);


Post your current code here. So that we can judge from there.



I did just change the
'This Task is probably left over from testing. It should probably be deleted.',
'Test C;ass Test',

Got a clean test, but back to 45% coverage.
Scott HolmanScott Holman

 if (TaskSubject == 'Pharmacy Demo Completed')

This condition is not tested in your test class.  It contains the other 55% of the untested code.


That did the trick! One simple change and I now have 100% coverage!

Michael L. Milner
Senior Business Intelligence Analyst / Salesforce Administrator
10100 Reunion Place, Suite 700, San Antonio, Texas 78216
o 210-587-3486 ext. 132 / f 210-576-0420


[cid:image002.png@01CEB8F4.2EDCDB00] [cid:image003.png@01CEB8F4.2EDCDB00] [cid:image004.png@01CEB8F4.2EDCDB00] [cid:image005.png@01CEB8F4.2EDCDB00]
CaptureRx is a DBA under NEC Networks LLC. The information in this
email may be confidential and/or privileged. This email is intended
to be reviewed only by the individual or organization named above.
If you are not the intended recipient or an authorized representative
of the intended recipient, you are hereby notified that any review,
dissemination or copying of this email and its attachments, if any, and
any use or disclosure of the information contained herein, is prohibited.
If you have received this email in error, please immediately notify
the sender by email or telephone and permanently delete this email
from your system.