+ Start a Discussion
Money CareMoney Care 

Test class Increase

Hi Guys

I have created a class and written test class for this but i have able to code coverage 64%.i am trying to 75% but i am not getting excat .
can anyone help me for this .
public class FormCurriculumController { 
  

public Purchase_Order__c curriculum {get; set;}
public Boolean privacy {get; set;}
public Boolean saved {get; set;}
public String styleClass {get; set;}

public Transient Blob resume {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}
      
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;


//ublic FormCurriculumController () {
    //curriculum = new Purchase_Order__c();
    //saved = false;
//}

  public FormCurriculumController(ApexPages.StandardController controller) {

        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        curriculum= new Purchase_Order__c();
        curriculum= (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
       
        if(curriculum.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(curriculum.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        curriculum.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        curriculum.Quote__c = quote.id;
        curriculum.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            curriculum.RecordTypeId = c1RecordTypeId;
        }
        else {
            curriculum.RecordTypeId = c2RecordTypeId;
        }
    }

    


public PageReference save() {
    try {
     
        if (!privacy) {
        
            ApexPages.Message reqMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please upload recent Purchase Order  before saving the record');
            ApexPages.addMessage(reqMsg);
            return null;
        }


        
       
        
        
        insert(curriculum);
     
        if (resume != null) {
            Attachment attach = new Attachment();
            attach.Body = resume;
            attach.Name = fileName;
            attach.ContentType= contentType;
            attach.ParentId = curriculum.id;                
            try {
                insert(attach);
                return new PageReference('/'+curriculum.id);

            } catch (Exception ex) {
               

                ApexPages.addMessages(ex);
                return null;
            }                    
        }

        update curriculum;

        saved = true;

    } 
    catch(Exception ex) {
        ApexPages.addMessages(ex);  
    }
    return null;   
}
}
 
@IsTest
public class TestFormCurriculumController  
{
static testMethod void TestMethodFormCurriculumController  ()
{

        account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C1'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
      
       
        insert sco;
    
         test.startTest();
         PageReference pageRef = Page.FormCurriculumController ;
         Test.setCurrentPage(pageRef);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(sco);
         
         ApexPages.currentPage().getParameters().put('Id',sco.id);
         FormCurriculumController  objMyController= new FormCurriculumController  (sc);
         
         
         
         
         
         
         /*ApexPages.currentPage().getParameters().put('Id',emp.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('id',sco.id);
           
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            NewSalesConfirmationExtension objMyController  = new NewSalesConfirmationExtension (stdLead);*/
            objMyController.save();
            
         
        test.stopTest();
        
        
        }
static testMethod void TestMethodFormCurriculumController1()
{

 account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        RecordType quoteRt = [Select id,name from RecordType where SobjectType='Quote__c' and Name='C2'];
        
        Quote__c qt=new Quote__c(RecordTypeId=quoteRt.id,Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C2'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
        insert sco;
        
         test.startTest();
            //ApexPages.currentPage().getParameters().put('id',sco.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('quoteId',qt.id);
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            FormCurriculumController  objMyController  = new FormCurriculumController (stdLead);
            objMyController.fileName='Test Class';
           
            objMyController.contentType='XYZ';
           
            objMyController.resume=Blob.valueOf('Unit Test Attachment Body');
            
            objMyController.save();
            
            
            
         
        
        test.stopTest();
        
        }
        
        
}


 
Best Answer chosen by Money Care
Amit Chaudhary 8Amit Chaudhary 8
Try below test class
@IsTest
public class TestFormCurriculumController  
{
static testMethod void TestMethodFormCurriculumController  ()
{

        account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C1'];
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
      
       
        insert sco;
    
         test.startTest();
         PageReference pageRef = Page.FormCurriculumController ;
         Test.setCurrentPage(pageRef);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(sco);
         
				
        // ApexPages.currentPage().getParameters().put('setDefaultValues','true');
         ApexPages.currentPage().getParameters().put('Id',sco.id);
         FormCurriculumController  objMyController= new FormCurriculumController  (sc);
		 objMyController.privacy = false;
 		 objMyController.save();
         
        test.stopTest();
        
        
        }
static testMethod void TestMethodFormCurriculumController1()
{

 account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        RecordType quoteRt = [Select id,name from RecordType where SobjectType='Quote__c' and Name='C2'];
        
        Quote__c qt=new Quote__c(RecordTypeId=quoteRt.id,Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C2'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
        insert sco;
        
         test.startTest();
            //ApexPages.currentPage().getParameters().put('id',sco.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('quoteId',qt.id);
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            FormCurriculumController  objMyController  = new FormCurriculumController (stdLead);
			objMyController.privacy = true ;
            objMyController.fileName='Test Class';
            objMyController.contentType='XYZ';
            objMyController.resume=Blob.valueOf('Unit Test Attachment Body');
            objMyController.save();
        test.stopTest();
        
        }
        
        
}

 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please try below code and let us know if this will help you
@IsTest
public class TestFormCurriculumController  
{
static testMethod void TestMethodFormCurriculumController  ()
{

        account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C1'];
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
      
       
        insert sco;
    
         test.startTest();
         PageReference pageRef = Page.FormCurriculumController ;
         Test.setCurrentPage(pageRef);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(sco);
         
				
        // ApexPages.currentPage().getParameters().put('setDefaultValues','true');
         ApexPages.currentPage().getParameters().put('Id',sco.id);
         FormCurriculumController  objMyController= new FormCurriculumController  (sc);
		 objMyController.save();
         
        test.stopTest();
        
        
        }
static testMethod void TestMethodFormCurriculumController1()
{

 account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        RecordType quoteRt = [Select id,name from RecordType where SobjectType='Quote__c' and Name='C2'];
        
        Quote__c qt=new Quote__c(RecordTypeId=quoteRt.id,Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C2'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
        //insert sco;
        
         test.startTest();
            //ApexPages.currentPage().getParameters().put('id',sco.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('quoteId',qt.id);
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            FormCurriculumController  objMyController  = new FormCurriculumController (stdLead);
            objMyController.fileName='Test Class';
            objMyController.contentType='XYZ';
            objMyController.resume=Blob.valueOf('Unit Test Attachment Body');
            objMyController.save();
        test.stopTest();
        
        }
        
        
}

let us know if this will help you
 
Money CareMoney Care
Hi Amit Chaudhary 

I have tried this modification ,but there is nothing increase in code coverage.i have checked in console see this lines are not covered ...User-added image
Amit Chaudhary 8Amit Chaudhary 8
Issue is coming because you are trying to insert same record (Purchase_Order__c sco) again in your apex class. Try to modify your code like below :-
Update your Apex class like below
NOTE:- i just added ! Test.isRunningTest() to avoid insert
public class FormCurriculumController { 
  

public Purchase_Order__c curriculum {get; set;}
public Boolean privacy {get; set;}
public Boolean saved {get; set;}
public String styleClass {get; set;}

public Transient Blob resume {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}
      
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;


//ublic FormCurriculumController () {
    //curriculum = new Purchase_Order__c();
    //saved = false;
//}

  public FormCurriculumController(ApexPages.StandardController controller) {

        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        curriculum= new Purchase_Order__c();
        curriculum= (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
       
        if(curriculum.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(curriculum.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        curriculum.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        curriculum.Quote__c = quote.id;
        curriculum.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            curriculum.RecordTypeId = c1RecordTypeId;
        }
        else {
            curriculum.RecordTypeId = c2RecordTypeId;
        }
    }

    


public PageReference save() {
    try {
     
        if (!privacy) {
        
            ApexPages.Message reqMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please upload recent Purchase Order  before saving the record');
            ApexPages.addMessage(reqMsg);
            return null;
        }


        
       
        
		if( ! Test.isRunningTest() )
		{	
			insert(curriculum);
		}
		
        if (resume != null) {
            Attachment attach = new Attachment();
            attach.Body = resume;
            attach.Name = fileName;
            attach.ContentType= contentType;
            attach.ParentId = curriculum.id;                
            try {
                insert(attach);
                return new PageReference('/'+curriculum.id);

            } catch (Exception ex) {
               

                ApexPages.addMessages(ex);
                return null;
            }                    
        }

        update curriculum;

        saved = true;

    } 
    catch(Exception ex) {
        ApexPages.addMessages(ex);  
    }
    return null;   
}
}


Let us know if this will help you
 
Money CareMoney Care
Hi Amit

i checked the modified code,but same 64% code coverage .this is the errorUser-added image
Amit Chaudhary 8Amit Chaudhary 8
Try below test class
@IsTest
public class TestFormCurriculumController  
{
static testMethod void TestMethodFormCurriculumController  ()
{

        account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C1'];
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
      
       
        insert sco;
    
         test.startTest();
         PageReference pageRef = Page.FormCurriculumController ;
         Test.setCurrentPage(pageRef);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(sco);
         
				
        // ApexPages.currentPage().getParameters().put('setDefaultValues','true');
         ApexPages.currentPage().getParameters().put('Id',sco.id);
         FormCurriculumController  objMyController= new FormCurriculumController  (sc);
		 objMyController.privacy = false;
 		 objMyController.save();
         
        test.stopTest();
        
        
        }
static testMethod void TestMethodFormCurriculumController1()
{

 account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        RecordType quoteRt = [Select id,name from RecordType where SobjectType='Quote__c' and Name='C2'];
        
        Quote__c qt=new Quote__c(RecordTypeId=quoteRt.id,Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C2'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
        insert sco;
        
         test.startTest();
            //ApexPages.currentPage().getParameters().put('id',sco.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('quoteId',qt.id);
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            FormCurriculumController  objMyController  = new FormCurriculumController (stdLead);
			objMyController.privacy = true ;
            objMyController.fileName='Test Class';
            objMyController.contentType='XYZ';
            objMyController.resume=Blob.valueOf('Unit Test Attachment Body');
            objMyController.save();
        test.stopTest();
        
        }
        
        
}

 
This was selected as the best answer
Money CareMoney Care
Thanks Amit