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

URGENT---->test method:: how to test a pagerefrence method in apex:

hi everyone!!

I am creating a test method I m new to this so can anybody please help me regarding this. my apex code is:

public PageReference redirectToTutorial(){
        if(ApexPages.currentPage().getParameters().get('articleName') != null){
            return null;
        DataCategoryHelper helper = DataCategoryHelper.getHelper('KnowledgeArticleVersion');
        String currentType;
        String currentArticleCategory;
        currentType = ApexPages.currentPage().getParameters().get('type');
        PageReference pg = null;
        Tutorial__kav currentArticle;
        List<Tutorial__kav> articleList = [select  URLName, id, Tutorial_Article_Text__c,(select DataCategoryGroupName, DataCategoryName From DataCategorySelections) from Tutorial__kav where knowledgeArticleId=:ApexPages.currentPage().getParameters().get('Id') and publishstatus='Online'];
        if(articleList != null && articleList.size() > 0){
            currentArticle = articleList.get(0);
            if(currentArticle.DataCategorySelections.size() > 0){
                currentArticleCategory = currentArticle.DataCategorySelections.get(0).DataCategoryName;
        pg = Page.MarketoTutorial;
        pg.getParameters().put('Id', ApexPages.currentPage().getParameters().get('Id'));
        pg.getParameters().put('articleName', currentArticle.URLName);
        pg.getParameters().put('tutorialName', currentArticleCategory);
        return pg.setRedirect(true);


Sry to say bt the link provided by you is not working so please give me the correct link..






i have updated the link, try it now