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
beenish khan 1beenish khan 1 

Test Class for project

Hello Every one 
I am new to salesforce and apex and i am writing a test class for my controller but it is covering 0% of my code if any one can help me with the test class

Apex Controller/Class
public with sharing class propertycontrollerdetail {
public seit__Property__c ppo {get; set;}
  
    
    public propertycontrollerdetail(ApexPages.StandardController controller)
    {
       ppo = new seit__Property__c();
    }
    
    public pageReference SaveA()
    {
        try{
         upsert ppo;
        PageReference pageRef = new PageReference('https://itroos-dev-ed--seit.na34.visual.force.com/apex/Property');
        pageRef.setRedirect(true);
        return pageRef;  
        }
        catch(Exception ex)
        {
           ApexPages.addMessages(ex);
		 system.debug(ex);
		 PageReference pageRef = new PageReference('https://itroos-dev-ed.my.salesforce.com/a01/o');
        pageRef.setRedirect(true);
       
        throw ex;
        }
    }
}

Test Class
@isTest
public class TestPropertyController{
  
    static testMethod void saveA(){
    
        Property__c pro = new Property__c( seit__Address__c = 'Lalazkhbhjkgar',seit__Description__c='sghj sjgh ',seit__Size__c='10 Marla',seit__Size_in_sq_ft__c='12000',seit__Status__c='Sold',seit__Type__c='Residential');
        try
        {
        insert pro;
            System.debug('Insert Successfull');
        }
        catch(Exception ex)
        {
            System.debug(ex.getMessage());
        }
       
	ApexPages.StandardController sc = new ApexPages.standardController(pro);

	propertycontrollerdetail controller = new propertycontrollerdetail(sc);
        
    }
}

If any one can help me with the  code i will appreciate it
AshlekhAshlekh
Hi,
 
@isTest
public class TestPropertyController{
  
    static testMethod void saveA(){

    Property__c pro = new Property__c( seit__Address__c = 'Lalazkhbhjkgar',seit__Description__c='sghj sjgh ',       seit__Size__c='10 Marla',seit__Size_in_sq_ft__c='12000',seit__Status__c='Sold',seit__Type__c='Residential');
insert pro;
         ApexPages.StandardController sc = new ApexPages.standardController(pro);
         Propertycontrollerdetail testAccPlan = new propertycontrollerdetail(sc);
         PageReference pageRef = Page.YOURPAGENAME;
         pageRef.getParameters().put('id', String.valueOf(pro.Id));
         Test.setCurrentPage(pageRef);
         propertycontrollerdetail controller = new propertycontrollerdetail(sc);
         controller.SaveA();

    }
}
-Thanks
Ashlekh Gera
 
beenish khan 1beenish khan 1
Hello Ashlekh
Thanks for the reply it is covering only 64% of the code how can i get the 80 % code coverage