You need to sign in to do that
Don't have an account?
Olavo Zapata
Test Class 100% in Sandbox but 0% coverage in Production
Hi guys,
I need help to deploy an apex trigger I saw that is very common to receive an error about coverage in production.
And I read many posts related to that but I couldn't fix it.
I completely new in apex triggers and deployment. I have a trigger that is working in sandbox and we make a test class to test it.
Code:
But in production it is showing me this message:
Thanks,
I need help to deploy an apex trigger I saw that is very common to receive an error about coverage in production.
And I read many posts related to that but I couldn't fix it.
I completely new in apex triggers and deployment. I have a trigger that is working in sandbox and we make a test class to test it.
Code:
@isTest(OnInstall=true) private class UpdateAccountId2 { public static List<Account> accountsList; public static List<nKPI__c> kpiList; public static String rdstation_id_account1; static void init(){ accountsList = new List<Account>(); kpiList = new List<nKPI__c>(); rdstation_id_account1 = '100'; kpiList.add(new nKPI__c( rdstationid__c = rdstation_id_account1 )); } /** Test with an existing account **/ static testMethod void testWithExistingAccount() { init(); Test.startTest(); accountsList.add(new Account( Name = 'Test', rdstationid__c = rdstation_id_account1 )); insert accountsList; insert kpiList; kpiList = [ SELECT Id, Account__c FROM nKPI__c WHERE Id = :kpiList[0].Id ]; // Verification System.assertEquals(kpiList[0].Account__c, accountsList[0].Id); Test.stopTest(); } }It shows me 100% coverage in sandbox when I run.
But in production it is showing me this message:
Your organization's code coverage is 70%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage. UpdateAccountId2Can anyone help me?
Thanks,
I don't know why was sending the test and the trigger in different deploys. Maybe my ignorance with apex.
But the solution was sending the Trigger and the Test at the same deploy.
Thanks for helping.
All Answers
paste your trigger as well
Thanks
I don't know why was sending the test and the trigger in different deploys. Maybe my ignorance with apex.
But the solution was sending the Trigger and the Test at the same deploy.
Thanks for helping.