I am trying to create a test class to move the apex trigger to production and i am getting only 42 % coverage and also i am unable to get the coverage option in developer console.
Here is my test class. Trigger works fine but dont know where am i going wrong. Please help me
PS: I am not a developer. Have minimum knowledge
@isTest
public class PRclosedate {
@isTest
static void test1() {
opportunity opp=new opportunity();
opp.CloseDate= System.today();
opp.id = '0063B000009YwB1QAK';
update(opp);
Test.startTest();
Test.stopTest();
}
}
Here is my trigger:
trigger PRdateschange on Opportunity (after Update) {
map<Id,Practice_Resource__c> mapPracResource = new map<Id,Practice_Resource__c> ();
if(Trigger.isUpdate){
list<Practice_Resource__c> opptyPR=new list<Practice_Resource__c>();
for(Opportunity oldOpp: Trigger.old)
{
for(Opportunity newOpp: Trigger.new)
{
if(oldOpp.id == newOpp.id && oldOpp.CloseDate != newOpp.CloseDate){
for(Practice_Resource__c otm : [SELECT Id,Opportunity__c, Start_Date__c,End_Date__c FROM Practice_Resource__c WHERE Opportunity__c IN : trigger.new]){
Practice_Resource__c PracRS =new Practice_Resource__c();
mapPracResource.put(otm.Opportunity__c,otm);
Integer noOfDays =oldOpp.CloseDate.daysBetween(newOpp.CloseDate);
Date prStartDate = otm.Start_Date__c;
Date newPrStDate = prStartDate.addDays(noOfDays);
PracRS.Start_Date__c = newPrStDate;
PracRS.Id = otm.Id;
Date prEndDate = otm.End_Date__c;
Date newPrEndDate = prEndDate.addDays(noOfDays);
PracRS.End_Date__c = newPrEndDate;
opptyPR.add(PracRS);
update opptyPR;
}
}
}
}
}
}