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
Akash Garg 2Akash Garg 2 

need test class for apex class


Please help to write the TEST class for the following apex class:-
public with sharing class Controller_QuotePage {
   public Opportunity qt {get; set;}
   public List<Opportunity_Product__c> theLineItems {get; set;}
   public Controller_QuotePage(ApexPages.StandardController controller) 
       Id quoteID = ((Opportunity) controller.getRecord()).Id;
    public List<Opportunity_Product__c> getLineItems(){
         return theLineItems;

   private void loadQuote(String quoteId) {
        this.qt = [Select Id, Name       
                   FROM Opportunity where    
   private void loadQuoteLineItems(String quoteId) {

       this.theLineItems = [SELECT Id, Name                          
                             FROM Opportunity_Product__c WHERE Opportunity__c =:   


Manoj DegaManoj Dega
Hi Akash,

Please find this code. Hope it helps for you.
public class Controller_QuotePageTest{
	static testMethod void cpq(){
		Opportunity opt = new Opportunity (); = 'Test Opportunity';
			opt.StageName = 'prospecting';
			opt.closedate =;
			insert opt;
		Opportunity_Product__c oppProduct = new Opportunity_Product__c();
			oppProduct.Opportunity__c =;
			insert oppProduct;
			ApexPages.StandardController sc = new ApexPages.StandardController(opt);
			Controller_QuotePage testAccPlan = new Controller_QuotePage(sc);

Please choose the best answer, if this helps you.
Thank you