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
sekharasekhara 

test cases for Building a Custom List Controller

 

Hi ,
Can any one help to write a test case for the following Apex Classes.
Apex Class:

public class Tva_ExportContactsExtension {
  public Tva_ExportContactsExtension(ApexPages.StandardSetController controller)
   {
     controller.setPageSize(controller.getResultSize());
  }
}

 

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

Try this :

 

 

@isTest
private class Test
{
static testmethod void TestController()
 {
      List<Contact> conLst = new List<Contact>() ;
      conLst.add(new Contact()) ;
      ApexPages.StandardsetController con = new ApexPages.StandardsetController(conLst);
      Tva_ExportContactsExtension x = new Tva_ExportContactsExtension(con);
     
 }
}

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

 

All Answers

sekharasekhara

I tried Test case for it But i got Error

 

@isTest
private class Test
{
static testmethod void TestController()
 {
      ApexPages.StandardsetController con = new ApexPages.StandardsetController(new Contact());
      Tva_ExportContactsExtension x = new Tva_ExportContactsExtension(con);
     
      }
 }

 

error is : Compile Error: Constructor not defined: [ApexPages.StandardSetController].<Constructor>(SOBJECT:Contact) at line 6 column 45

Ankit AroraAnkit Arora

Try this :

 

 

@isTest
private class Test
{
static testmethod void TestController()
 {
      List<Contact> conLst = new List<Contact>() ;
      conLst.add(new Contact()) ;
      ApexPages.StandardsetController con = new ApexPages.StandardsetController(conLst);
      Tva_ExportContactsExtension x = new Tva_ExportContactsExtension(con);
     
 }
}

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

 

This was selected as the best answer
sekharasekhara

@ Ankit_Arora :

Thank q I got the required result.

sunny@99-chgsunny@99-chg

Hai Ankit,

 

Please help me,I am struggling with this Task. I need TestCoverage for IdeaStandardSetController.

For my constructor like:

 

public class MyIdeaProfileExtension12 {
private final ApexPages.IdeaStandardSetController ideaSetController;
public MyIdeaProfileExtension12(ApexPages.IdeaStandardSetController controller) {
ideaSetController = (ApexPages.IdeaStandardSetController)controller;

==========================

==========================

==========================
}

public List<Idea> getModifiedIdeas() {

Idea[] ideas = ideaSetController.getIdeaList();
return ideas;
}

 

For my DEV Ideas and related to ideas are Enabled.

Need Urget, For the above Red color constructor.I tried in Many ways.but coudnt find Result

How to call that Constructor Through Constructor..