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
.Net Api.Net Api 

Query string is not covered in code coverage ?

Hi ,

             I am using a method which gets the query string and the red marked line is not covered in the code coverage ,please let me know how to solve this issue and why it is not covered in the code coverage waiting for the immediate response .

 

Below is the code snippet

 

public Integer getPageNumber()
{
    String count;
   if ( ApexPages.currentPage().getParameters().get('page') != null)
    {
         count=ApexPages.currentPage().getParameters().get('page');
    }
    Integer iPageNumber=Integer.ValueOf(count);
    return iPageNumber;
}

 

Regards,

vasu

kiranmutturukiranmutturu

u have to wrtite this before calling getPageNumber method

 ApexPages.currentPage().getParameters().put('page', appropriatevalue);

.Net Api.Net Api

Dear kiran ,

                            In code coverage it is showing still in red color only ,the below highlighted red color is not covering in the code coverage .

 

public Integer getPageNumber()
{
    String count;
   if ( ApexPages.currentPage().getParameters().get('page') != null)
    {
         ApexPages.currentPage().getParameters().Put('page',count);
    }
    Integer iPageNumber=Integer.ValueOf(count);
    return iPageNumber;
}

 

 

Regards,

Vasu

kiranmutturukiranmutturu

post me your test code

Shashikant SharmaShashikant Sharma

Could you please share your test method.

aballardaballard

Are you using Test..setCurrentPageReference() to specify the page being tested?   If so, have you tried setting the parameters on that page reference before running the test code?