• Matthew A Small
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies
Hi everyone. 
I am relatively new to writing test classes and I am creating a package. 

I get this error when I try to upload into the package. 
User-added image

Here is my test class

@isTest
private class CheckInShiftCreateCtrlTest {
  
  
  @isTest static void testConstructor_ParentShiftExist() {
    Shift__c shift= new Shift__c();
    insert shift;
    shift= [select Id, Name from Shift__c where id = : shift.id];
    

    Contact_Report__c contRepForInsert = new Contact_Report__c(
      Shift__c = shift.Id
    );
    insert contRepForInsert;

    Test.setCurrentPage(Page.CheckInCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInShiftCreateCtrl ctrl = new CheckInShiftCreateCtrl(sc);
    Test.stopTest();

    System.assertEquals(shift.Id, ctrl.contactRep.Shift__c);
  }
  
  @isTest static void testConstructor_NoParentShift() {
    Contact_Report__c contRepForInsert = new Contact_Report__c();
    insert contRepForInsert;

    Test.setCurrentPage(Page.CheckInCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInShiftCreateCtrl ctrl = new CheckInShiftCreateCtrl(sc);
    Test.stopTest();

    System.assert(ctrl.contactRep != null);
  }

  @isTest static void testRefreshFilterResult() {
    
    Shift__c shift2= new Shift__c();
    insert shift2;
    shift2= [select Id, Name from Shift__c where id = : shift2.id];
    
    Shift__c contRepForInsert = new shift__c();
    insert contRepForInsert;
    contRepForInsert= [select Id, Name from Shift__c where id = : contRepForInsert.id];
    
      

    Test.setCurrentPage(Page.CheckInCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInShiftCreateCtrl ctrl = new CheckInShiftCreateCtrl(sc);
    ctrl.selectedShiftName = 'test';
    ctrl.refreshFilterResults();
    Integer countRecords1 = ctrl.allFilteredShift.size();

    ctrl.selectedShiftName = '';
    ctrl.refreshFilterResults();
    Integer countRecords2 = ctrl.allFilteredShift.size();

    ctrl.selectedShiftName = 'testShift2';
    ctrl.refreshFilterResults();
    Integer countRecords3 = ctrl.allFilteredShift.size();  

    Test.stopTest();

    System.assertEquals(3, countRecords1);
    System.assertEquals(3, countRecords2);
    System.assertEquals(2, countRecords3);
  }

  @isTest static void testSelectShift() {
    Shift__c shift = new Shift__c();
    insert shift ;
    shift= [select Id, Name from Shift__c where id = : shift.id];
    Shift__c shift2 = new Shift__c();
    shift2= [select Id, Name from Shift__c where id = : shift2.id];
    insert new List<Shift__c>{shift, shift2};


Shift__c contRepForInsert = new Shift__c();
       insert contRepForInsert ;
    contRepForInsert = [select Id, Name from Shift__c where id = : contRepForInsert .id];
    

    Test.setCurrentPage(Page.ContactReportCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInCreateCtrl ctrl = new CheckInCreateCtrl(sc);
    
     
    ctrl.refreshFilterResults();
    ApexPages.CurrentPage().getparameters().put('shiftName', 'testShift2');
    
    Test.stopTest();

    System.assertEquals(shift.Id, ctrl.contactRep.Shift__c);
  }
  }




Can anyone help? 
 
Hi everyone. 
I am relatively new to writing test classes and I am creating a package. 

I get this error when I try to upload into the package. 
User-added image

Here is my test class

@isTest
private class CheckInShiftCreateCtrlTest {
  
  
  @isTest static void testConstructor_ParentShiftExist() {
    Shift__c shift= new Shift__c();
    insert shift;
    shift= [select Id, Name from Shift__c where id = : shift.id];
    

    Contact_Report__c contRepForInsert = new Contact_Report__c(
      Shift__c = shift.Id
    );
    insert contRepForInsert;

    Test.setCurrentPage(Page.CheckInCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInShiftCreateCtrl ctrl = new CheckInShiftCreateCtrl(sc);
    Test.stopTest();

    System.assertEquals(shift.Id, ctrl.contactRep.Shift__c);
  }
  
  @isTest static void testConstructor_NoParentShift() {
    Contact_Report__c contRepForInsert = new Contact_Report__c();
    insert contRepForInsert;

    Test.setCurrentPage(Page.CheckInCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInShiftCreateCtrl ctrl = new CheckInShiftCreateCtrl(sc);
    Test.stopTest();

    System.assert(ctrl.contactRep != null);
  }

  @isTest static void testRefreshFilterResult() {
    
    Shift__c shift2= new Shift__c();
    insert shift2;
    shift2= [select Id, Name from Shift__c where id = : shift2.id];
    
    Shift__c contRepForInsert = new shift__c();
    insert contRepForInsert;
    contRepForInsert= [select Id, Name from Shift__c where id = : contRepForInsert.id];
    
      

    Test.setCurrentPage(Page.CheckInCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInShiftCreateCtrl ctrl = new CheckInShiftCreateCtrl(sc);
    ctrl.selectedShiftName = 'test';
    ctrl.refreshFilterResults();
    Integer countRecords1 = ctrl.allFilteredShift.size();

    ctrl.selectedShiftName = '';
    ctrl.refreshFilterResults();
    Integer countRecords2 = ctrl.allFilteredShift.size();

    ctrl.selectedShiftName = 'testShift2';
    ctrl.refreshFilterResults();
    Integer countRecords3 = ctrl.allFilteredShift.size();  

    Test.stopTest();

    System.assertEquals(3, countRecords1);
    System.assertEquals(3, countRecords2);
    System.assertEquals(2, countRecords3);
  }

  @isTest static void testSelectShift() {
    Shift__c shift = new Shift__c();
    insert shift ;
    shift= [select Id, Name from Shift__c where id = : shift.id];
    Shift__c shift2 = new Shift__c();
    shift2= [select Id, Name from Shift__c where id = : shift2.id];
    insert new List<Shift__c>{shift, shift2};


Shift__c contRepForInsert = new Shift__c();
       insert contRepForInsert ;
    contRepForInsert = [select Id, Name from Shift__c where id = : contRepForInsert .id];
    

    Test.setCurrentPage(Page.ContactReportCreate);
    ApexPages.CurrentPage().getparameters().put('pid', contRepForInsert.Id);
    
    Test.startTest();
        ApexPages.StandardController sc = new ApexPages.standardController(contRepForInsert);
    CheckInCreateCtrl ctrl = new CheckInCreateCtrl(sc);
    
     
    ctrl.refreshFilterResults();
    ApexPages.CurrentPage().getparameters().put('shiftName', 'testShift2');
    
    Test.stopTest();

    System.assertEquals(shift.Id, ctrl.contactRep.Shift__c);
  }
  }




Can anyone help? 
 
Is there something special that I have to do to have ProcessBuilder findmy email templates?