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 

How to increae Code Coverage

I am writing a test class for the controller but it is covering only 64% of the code how i can increase the code coverage
Here is my Controller
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;
        }
    }
}
and my test class is
@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.Property;
         pageRef.getParameters().put('id', String.valueOf(pro.Id));
         Test.setCurrentPage(pageRef);
         propertycontrollerdetail controller = new propertycontrollerdetail(sc);
         controller.SaveA();

    }
}


 
Prad NethasPrad Nethas
Hey Khan,

Can you tell me which lines are not covered, so that I can help you out if possible.

Regards
Prad