You need to sign in to do that
Don't have an account?
garfer
Because I can not cover 100% a class that was already covered
Hello,
I have a problem, I created a class in eclipse that runs correctly in production. When I want more code appends, I class covers only 23%. I add the code that's just an assignment of values to a new field of the object.
The strange thing is that I leave the class as it was running in production, and covers me 100%, in theory should cover, as this same code is running currently in production.
In order opportunity to add some custom field
Someone can help me solve this problem ...
thanks
Hi,
Though the exact cause analysis can be done if one goes through the code.
Yes it may happen that:-
Hope this helps...
A class having 100 % code coverage in Sandbox may have less code coverage in the production because of some dependencies.So, its not always same.However, if there is a big difference in the coverage of Sandbox and Production then you should debug the code in the production by running the runtest for the that class ans see what code is not getting covered.
If you want to extend your functionality then you must review the test class as well in sandbox to make sure you have sufficient code coverage and then deploy the apex class and test class again.
There may be plenty of reasons for the low code coverage and I dont want to guess.Would be great if you post your code here in case you are not able to identify the root cause of the issue by debugging your code or log a case with salesforce.
CODE
global class BatchLeadPhones implementsDatabase.Batchable<sObject>{
publicString query, query1;
globaldatabase.querylocator start(Database.BatchableContext BC){
query='Select Id, Name, Nombre_del_Cliente__c, Proceso__c,Fecha_de_Pago__c, Mes_de_validacion__c From Factura__c Where Proceso__c='No validado' ';
returnDatabase.getQueryLocator(query);
}
globalvoid execute(Database.BatchableContext BC, List<sObject> scope){
List<Factura__c> Leads = new List<Factura__c>();
for(sObject s : scope){
Factura__c l = (Factura__c)s;
for(List<Opportunity> st : [SELECT Id, Numero_de_la_Factura__c, Status_de_Oportunidad__c,
Status_Factura__c FROMOpportunityWHERE Numero_de_la_Factura__c =: l.Name]){
for(Opportunityopor:st){
if (opor.Numero_de_la_Factura__c == l.Name){
opor.Status_Factura__c ='Pagada';
l.Proceso__c 'Terminado';
opor.Fecha_de_pago__c=l.Fecha_de_Pago__c;
}
}
updatest;
}
Leads.Add(l);
}
update Leads;
}
globalvoidfinish(Database.BatchableContext BC){
}
// test method
static testMethod void test_BatchLeadPhones() {
Test.StartTest();
BatchLeadPhones Blp =
newBatchLeadPhones();
ID batchprocessid = Database.executeBatch(Blp);
Test.StopTest();
}
}
Can you pls post the error????
This is the error that throws me when I run the test run.
"The average test coverage of all classes and Apex triggers is 23%, requires a minimum test coverage of 75%"
From line 9 sends the problem:
My class (ApexClass) - -13 lines not tested, 24% covered
This code is currently being used in production, do not understand why send the code coverage issue.
thanks for you help