function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bhaveshkjogibhaveshkjogi 

test case problem with Return statement... How to write ?

Hi all,  I want to write the detail of the test case,  how to write:  

 

global List<Quote> loQuote = null;

global virtual void Initialize()
{
loQuote = [select Id, OpportunityId,
Quote_Date__c, Pricebook2Id, Tax_Date__c, Tax_Now_Status__c, Non_Taxable__c, TotalPrice,
ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry,
BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, ShippingHandling,
(select Id, Pricebookentry.product2.ProductCode, Description, Pricebookentry.product2,
Quantity, TotalPrice, Sales_Tax_Amount__c, Rate__c, Sales_Tax_Details__c, UnitPrice from QuoteLineItems)
from Quote where id =:apCurPage];

if(0 == loQuote.size())
{
loQuote = new List<Quote>();
loQuote.add(new Quote());
}
loQuoteLines = loQuote[0].QuoteLineItems;

loOpp = [select Account.Id, Account.Name from Opportunity where id =:loQuote[0].OpportunityId];
}
global override virtual string ShouldCalcTax()
{
if(loQuote.size() < 1)
return 'testing';
}

souvik9086souvik9086

^^ Duplicate Post

http://boards.developerforce.com/t5/Apex-Code-Development/Test-method-for-quot-return-statement-quot/td-p/662762

 

Try like this

 

global List<Quote> loQuote = null;

global virtual void Initialize()
{
loQuote = [select Id, OpportunityId,
Quote_Date__c, Pricebook2Id, Tax_Date__c, Tax_Now_Status__c, Non_Taxable__c, TotalPrice,
ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry,
BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, ShippingHandling,
(select Id, Pricebookentry.product2.ProductCode, Description, Pricebookentry.product2,
Quantity, TotalPrice, Sales_Tax_Amount__c, Rate__c, Sales_Tax_Details__c, UnitPrice from QuoteLineItems)
from Quote where id =:apCurPage];

if(0 == loQuote.size())
{
loQuote = new List<Quote>();
loQuote.add(new Quote());
}
loQuoteLines = loQuote[0].QuoteLineItems;

loOpp = [select Account.Id, Account.Name from Opportunity where id =:loQuote[0].OpportunityId];
}
global override virtual string ShouldCalcTax()
{
if(loQuote.size() < 1){
return 'testing';

}

else{

return NULL;

}

}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

bhaveshkjogibhaveshkjogi

Hi, souvik9086

 

 

can you tell me how to write this in controller?

 

in example... i dont know how to write test case of this.

 

i am creating package of this and i got 69% code coverage...

 

so i am writing test case of remaining.. to reach 75%.....

 

Please tell me how to Write this in Controller...