You need to sign in to do that
Don't have an account?

test class I can't get 75% coverage but only 33%
This is the class:
and this is the test
I can get only 33% of coverage.
Any Ideas?
Thank you in advance
public without sharing class calculatorController { @AuraEnabled public static void saveOpp (Id oppId, Decimal netto, Decimal capfin, Decimal comm, Decimal durata, Decimal interessi, Decimal rata, Decimal tan, String finalita, Id istituto ) { try { Opportunity queriedOpp = [SELECT Id, Prev_Netto_Erogato__c, Amount FROM Opportunity WHERE Id = :oppId LIMIT 1]; queriedOpp.Prev_Netto_Erogato__c = netto; queriedOpp.Prev_Capitale_Finanziato__c = capfin; queriedOpp.Prev_Commissioni__c = comm; queriedOpp.Prev_Durata__c = durata; queriedOpp.Prev_Interessi__c = interessi; queriedOpp.Prev_Rata__c = rata; queriedOpp.Tan__c = tan; queriedOpp.Prev_Finalita__c = finalita; queriedOpp.Prev_Istituto_Finanziario__c = istituto; update queriedOpp; } catch(Exception e) { System.debug('An unexpected error has occurred: ' + e.getMessage()); } } }
and this is the test
@isTest private class calculatorControllerTEST { private static testMethod void saveOppTEST () { date d1 = date.newInstance(2016,01,12); Opportunity opp = new Opportunity(Name='aaa', CloseDate=d1, StageName='Qualificata'); insert opp; calculatorController ctrl = new calculatorController (); calculatorController.saveOpp('0061j00000235a7', 333, 333, 333, 333, 333, 333, 3, 'CQS', '0011j000002GwXp'); } }
I can get only 33% of coverage.
Any Ideas?
Thank you in advance
Update your code like below
Let us know if this will help you