You need to sign in to do that
Don't have an account?
Shunn
Apex class deployment without trigger or test class?
Hi All,
I am no developer. I have this test class in sandbox. I tried to deploy it to production and I am hitting a code coverage error(Code Coverage Failure. Your code coverage is 0%. You need at least 75% coverage to complete this deployment.
PBBRunAssignmentRules)
. see the class here:
// Digital Pi - This Apex class is used to reassign a lead using standard assignment rules
public with sharing class PBBRunAssignmentRules {
@InvocableMethod(label='Re-run Assignment Rules on Lead')
public static void ReRunAssignmentRules(list<string> recordIds) {
set<id> LeadIds = new set<id>();
for (string recordId:recordIds){
id rid=id.valueOf(recordId);
Schema.SObjectType sot= rid.getSObjectType();
if (sot == Lead.sObjectType){
LeadIds.add(rid);
}
}
if (!LeadIds.isempty()){
//ID jobID = System.enqueueJob(new PBBLeadReassignQueueable(LeadIds));
if (system.isFuture()) {
system.debug('running in future already; exiting!');
return;
} else {
system.debug('starting future call');
futureLeadReassign(LeadIds);
}
}
}
@future
public static void futureLeadReassign(Set<ID> ReassignSet) {
system.debug('in the future, doing lead reassignment');
List<Lead> UpdList = [SELECT Id FROM Lead WHERE Id IN: ReassignSet];
for (Lead l:UpdList) {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
// use leadAssignment rules when updating
l.setOptions(dmo);
}
system.debug(UpdList);
update(UpdList);
}
}
What do I need to do? Do I need a trigger or test class? Any help with writing this test class please?
I am no developer. I have this test class in sandbox. I tried to deploy it to production and I am hitting a code coverage error(Code Coverage Failure. Your code coverage is 0%. You need at least 75% coverage to complete this deployment.
PBBRunAssignmentRules)
. see the class here:
// Digital Pi - This Apex class is used to reassign a lead using standard assignment rules
public with sharing class PBBRunAssignmentRules {
@InvocableMethod(label='Re-run Assignment Rules on Lead')
public static void ReRunAssignmentRules(list<string> recordIds) {
set<id> LeadIds = new set<id>();
for (string recordId:recordIds){
id rid=id.valueOf(recordId);
Schema.SObjectType sot= rid.getSObjectType();
if (sot == Lead.sObjectType){
LeadIds.add(rid);
}
}
if (!LeadIds.isempty()){
//ID jobID = System.enqueueJob(new PBBLeadReassignQueueable(LeadIds));
if (system.isFuture()) {
system.debug('running in future already; exiting!');
return;
} else {
system.debug('starting future call');
futureLeadReassign(LeadIds);
}
}
}
@future
public static void futureLeadReassign(Set<ID> ReassignSet) {
system.debug('in the future, doing lead reassignment');
List<Lead> UpdList = [SELECT Id FROM Lead WHERE Id IN: ReassignSet];
for (Lead l:UpdList) {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
// use leadAssignment rules when updating
l.setOptions(dmo);
}
system.debug(UpdList);
update(UpdList);
}
}
What do I need to do? Do I need a trigger or test class? Any help with writing this test class please?
All Answers
You would need a Apex Test class to deploy this in production. It should also cover 75% of the APEX Class to make a succesful deployment.
Please get started here : https://trailhead.salesforce.com/en/content/learn/modules/apex_testing/apex_testing_intro
Regards,
Krishna Avva
In order to deploy the code, you need an APEX class. There is no workaround for this step. You can write it on your own or you may hire a developer on an hourly basis for the same. I believe that if it's a single class that needs testing then there won't be too much time required for this task.
can someone help me with test class?