
3 respostas
I have solved thank you :) the test class is:@isTestpublic class ImportoFatturato_Test{ static testMethod void Costruttore_Test() { Account acc = new Account(name='Test Account', billingStreet='Test', billingCity='Test',billingState='Test', billingCountry='Test'); insert acc; List<Opportunity> l_opp = new List<Opportunity>(); Opportunity opp = new Opportunity(); opp.Accountid = acc.id; opp.Name = 'test'; opp.StageName = 'Prospecting'; opp.CloseDate = date.today(); opp.Type = 'New Client'; opp.NextStep = 'Test'; opp.LeadSource = 'Business Development'; insert opp; l_opp.add(opp); test.startTest(); Product2 p2 = new Product2 (); List <Product2> Lp2 = new List <Product2>(); p2.name='test'; p2.IsActive=true; insert p2; Lp2.add(p2); Id pricebookId = Test.getStandardPricebookId(); List <PricebookEntry> Lpbe = new List <PricebookEntry>(); PricebookEntry pbe = new PricebookEntry (); pbe.Product2Id=p2.Id; pbe.IsActive=true; pbe.UnitPrice=1; pbe.Pricebook2Id=pricebookId; insert pbe; Lpbe.add(pbe); Quote preventivo = new Quote(Name = 'Test',OpportunityId = opp.id, N_Offerta__c = 'ciao', Pricebook2Id=pricebookId ); insert preventivo; QuoteLineItem qtl = new quotelineitem(quoteid = preventivo.id, quantity=1, unitprice=1, PricebookEntryId=pbe.id, Product2Id=p2.id); insert qtl; List<Riga_fattura__c> l_riga_f = new List<Riga_fattura__c>(); Riga_fattura__c riga_f = new Riga_fattura__c (); riga_f.Motivo_stato__c='Inviata1'; riga_f.Voce_preventivo__c=qtl.id; insert riga_f; riga_f.Motivo_stato__c='Bozza'; update riga_f; l_riga_f.add(riga_f); test.stopTest(); } }thank you very much for your help