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
pooja kasliwalpooja kasliwal 

getting an error while writing a test class for these class.

public class AddmultipleAccountsController {
    public String rowNumber { get; set; }
    public String cnt { get; set; }
    public String listAccount { get; set; }
Offer__c account = new Offer__c();
 
public list<Offer__c> listOffer{ get; set; }

public Offer__c del;
public Integer rowIndex {get;set;}
public List<Offer__c> dellistOffer {get;set;}

public AddmultipleAccountsController()
{
listOffer=new list<Offer__c>();
listOffer.add(account);
}


public PageReference deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
// System.debug('rowbe deleted ' + rowIndex );
 //System.debug('rowm to be deleted '+listOffer[rowIndex]);
 del = listOffer.remove(rowIndex);
 //dellistOffer.add(del);
 return Page.dy;
 
 }



Public void addAccount()
{
Offer__c acc = new Offer__c();
listOffer.add(acc);
}
public PageReference saveAccount() {
for(Integer i=0; i<listOffer.size(); i++)
{
insert listOffer;
}

return Page.dy;
}
}
ManojjenaManojjena
HI Pooja ,
What exactly the error you are getting ,Is it possible to post your test class code so that we can help you out .
Thanks
Manoj
 
sandeep sankhlasandeep sankhla
Hi,

Can you share the test code which you ahev written and error which you are getting ?

Thanks
 
pooja kasliwalpooja kasliwal
@isTest
public class TestAddmultipleAccountsController{
 static testmethod void validAccount()
 {
  string rowNumber='10';
  string cnt='10';
  String listAccount='Test';
   Offer__c of10=new Offer__c(Name='Test1');
  Insert of10;
  list<Offer__c> of1=[select id from offer__c where id=:of10.id];
 // AddmultipleAccountsController()=new AddmultipleAccountsController();
  List<Offer__c> of2=new List<Offer__c>();
  //of2.add(of1);
  AddmultipleAccountsController abc=new AddmultipleAccountsController();
  abc.addAccount();
  
 
 }
}
AshlekhAshlekh
Hi,

Please share the error message.

-Thanks
Ashlekh Gera