jeudi 16 avril 2020

Missing test class coverage(Code Coverage NON)

I have written a test class to create PDF on quote. Can anyone help me with the test class and make the code coverage as 90% at least. Since the logic of my test class is wrong/ The test class is success but code coverage is none Apex class public class QuotePDF { public boolean show{get;set;} public id pdtId{get;set;} public Quote op{get;set;} public QuoteLineItem oli{get;set;} public string pb{get;set;} public Id opid{get;set;} public id prodid{get;set;} public list OliList{get;set;} public list OliCreate; public integer deleteIndex{get;set;} public QuotePDF() { show=false; oli=new QuoteLineItem(); op=new Quote(); OliList=new list(); OliCreate=new list(); } public void save(){ pricebook2 spbid=[select id from pricebook2 where isStandard=true limit 1]; opportunity o1=[select id from opportunity limit 1]; op.OpportunityId=o1.id; op.Pricebook2Id=spbid.id; upsert op; mappdtTopbemap=new map(); for(pricebookentry pb:[select product2id,id from pricebookentry where pricebook2id =:spbid.id ]) { pdtTopbemap.put(pb.product2id,pb.id); } for(QuoteLineItem o:OliList) { o.QuoteId=op.id; o.unitprice=o.unitprice; o.quantity=o.quantity; o.pricebookentryid=pdtTopbemap.get(o.product2id); o.Product2Id=o.product2id; OliCreate.add(o); } insert OliCreate; } public void AddOli() { show=true; QuoteLineItem olitemp = new QuoteLineItem(); OliList.add(olitemp); } public void deleteOpp() { OliList.remove(deleteIndex); } } VF




{!$Organization.Name}
General Information Company Address: {!$Organization.Country} Quote Number:{!Quotes__c.Quote_Number__c} Expiration Date:
Contact Information Prepared By: Email:{!Quotes__c.Email__c}
Address Information Bil To: {!Quotes__c.Bill_To__c}

Ship To:{!Quotes__c.Quote_Number__c}
Product Details Product Name List Price Sales Price Quantity Total Price {!QuoteLine.Product2Id__r.Name} {!QuoteLine.ListPrice__c} {!QuoteLine.UnitPrice__c} {!QuoteLine.Quantity__c} {!QuoteLine.Total_Price__c}
Totals Sub Total:₹ Discount:₹ Total Price:₹ Tax:₹ Shipping and Handling:₹ Grand Total:₹
Quote Acceptance Information Signature:........................ Name:.............................. Title:.............................. Date:............................... Test Class @isTest Public class QuoteApexClassTest { @isTest public static void QuoteApextestMethod() { Opportunities__c opp = new Opportunities__c(); opp.Name = 'TestOpp'; opp.Close_Date__c = System.today() + 5; opp.Stage__c = 'Prospecting'; Insert opp; Quotes__c q = new Quotes__c(); q.Name = 'test'; q.OpportunityId__c = opp.Id; Insert q; ApexPages.StandardController sc = new ApexPages.StandardController(q); PageReference pageRef = Page.QuoteTemplate; pageRef.getParameters().put('id', String.valueOf(q.Id)); Test.setCurrentPage(pageRef); PageReference pref = Page.QuoteTemplate; pref.getParameters().put('id',opp.id); Test.setCurrentPage(pref); } }

Aucun commentaire:

Enregistrer un commentaire