You need to sign in to do that
Don't have an account?
SIB Admin
Code coverage less than 75%.How to exclude classes
Hi,
I am new to Salesforce testing.When I try to push a trigger class it says your code coverage is below 75%.I need to deploy it urgently.I tried running all tests and by going to developer console to check code coverage for each class.
Here is the screenshot
I am thinking if I could exclude the classes with miminal coverage from the code coverage so that they do not lower the overall code coverage.I tried that by annotating each class by @isTest but even after that when I tried run all tests and went to develop console I could still see those classes with 0% coverage.
I am new to Salesforce testing.When I try to push a trigger class it says your code coverage is below 75%.I need to deploy it urgently.I tried running all tests and by going to developer console to check code coverage for each class.
Here is the screenshot
I am thinking if I could exclude the classes with miminal coverage from the code coverage so that they do not lower the overall code coverage.I tried that by annotating each class by @isTest but even after that when I tried run all tests and went to develop console I could still see those classes with 0% coverage.
@isTest
public class CustomASR_CC extends CustomASR_New{
public List<Vendor_Service_Agreement__c> contracts {get; set;}
public List<Affected_Vendor_Account__c> vendorAccounts {get; set;}
public Decimal totalAnnualSavings {get; set;}
public Integer ccColspan {get; set;}
public CustomASR_CC() {
vendorAccounts = [SELECT Id, Name, Pre_SIB_Contract__c, Post_SIB_Contract__c
FROM Affected_Vendor_Account__c
WHERE Audit__c = :asr.Audit__c];
if(asr.Audit__r.Audit_Type__c == 'Waste - Solid, Recycling, & Compost'){
ccColspan = 10;
} else if(asr.Audit__r.Audit_Type__c == 'Telecom - Phone, Internet, & Television' || asr.Audit__r.Audit_Type__c == 'Telecom - Television'){
ccColspan = 10;
} else if(asr.Audit__r.Audit_Type__c == 'Waste - Medical'){
ccColspan = 10;
} else if(asr.Audit__r.Audit_Type__c == 'Armored Car Service'){
ccColspan = 9;
} else{
ccColspan = 9;
}
}
public List<CCExternal_Group> getCCExternal(){
List<CCExternal_Group> contractGroups = new List<CCExternal_Group>();
contracts = [SELECT Id, RecordType.Name, Vendor__r.Name, Effective_Date_of_Agreement__c, Initial_Term_Length__c, Renewal_Term_Length__c,
Current_Term_Expiration__c, Fuel_Environmental_Surcharges__c, Price_Increase_Controls__c, Contract_Type__c, Closure_Sale_or_Expiration_Penalty__c, X30_Day_Termination__c, Underlying_Servicer__c,
(SELECT Id, RecordType.Name, Vendor__r.Name, Effective_Date_of_Agreement__c, Initial_Term_Length__c, Renewal_Term_Length__c,
Current_Term_Expiration__c, Fuel_Environmental_Surcharges__c, Price_Increase_Controls__c, Contract_Type__c, Underlying_Servicer__c
FROM Vendor_Service_Agreements__r)
FROM Vendor_Service_Agreement__c
WHERE Audit__c = :asr.Audit__c AND RecordType.Name = 'Post-SIB'];
for(Vendor_Service_Agreement__c newContract : contracts){
CCExternal_Group ccGroup = new CCExternal_Group(newContract, this.auditedLocations);
contractGroups.add(ccGroup);
}
//Total Annual Savings
totalAnnualSavings = 0.00;
for(CCExternal_Group g : contractGroups){
totalAnnualSavings = totalAnnualSavings + g.newContract.getAnnualSavings();
}
List<CCExternal_Group> filteredGroups = new List<CCExternal_Group>();
for(CCExternal_Group g : contractGroups){
if(g.newContract.getAnnualSavings()>0){
filteredGroups.add(g);
}
}
filteredGroups.sort();
return filteredGroups;
}
@isTest
private class ASRInitializationTest {
//Create test data
@testSetup static void setupTestData(){
//Test Audit
testData.createTestAudit();
Location_Audits__c testAudit = [SELECT Id, Name, Audit_Type__c FROM Location_Audits__c WHERE Account__r.Name = 'Test Account'];
//Test Audit Definition
Audit_Definition__c testDefinition = new Audit_Definition__c(
Audit_Type__c = testAudit.Audit_Type__c
);
insert testDefinition;
testDefinition = [SELECT Id, Name, Audit_Type__c FROM Audit_Definition__c WHERE Audit_Type__c = :testAudit.Audit_Type__c];
//Test ASR Attribute
ASR_Attribute__c attr = new ASR_Attribute__c(
Audit_Definition__c = testDefinition.Id,
Section__c = 'Location Information',
Section_Label__c = 'My Section Label',
Object_Type__c = 'My_Object__c',
Field__c = 'My_Field__c',
Label__c = 'My_Label__c',
Hidden__c = false,
Order__c = 1
);
insert attr;
}
@isTest static void testASRCreate() {
//Create a new ASR and relate it to the test audit
Location_Audits__c testAudit = [SELECT Id, Name, Audit_Type__c FROM Location_Audits__c WHERE Account__r.Name = 'Test Account'];
ASR__c testASR = new ASR__c(
Audit__c = testAudit.Id,
ASR_Date__c = System.today()
);
insert testASR;
}
}