You need to sign in to do that
Don't have an account?
bonny mankotia
Test Class Code Coverage Show Only 66%
Hello Guys I need a Test Class for Below Class Please help me.
public with sharing class Accountcontactpicklist
{
public String selectedAccId{get;set;}
public String selectedConId{get;set;}
public List<SelectOption> getAccountNames()
{
List<SelectOption> accOptions= new List<SelectOption>();
accOptions.add( new SelectOption('','--Select--'));
for( Account acc : [select Id,name from Account where name like '[abc]%' limit 5 ] )
{
accOptions.add( new SelectOption(acc.Id,acc.name));
}
return accOptions;
}
public List<SelectOption> getContactNames()
{
List<SelectOption> conOptions= new List<SelectOption>();
List<SelectOption> options = new List<SelectOption>();
if(selectedAccId != null)
{
for( contact con : [select Id,name,accountid from contact where accountid=:selectedAccId ] )
{
conOptions.add( new SelectOption(con.Id,con.name));
}
}
else
{
conOptions.add( new SelectOption('--None--','--None--'));
}
return conOptions;
}
}
public with sharing class Accountcontactpicklist
{
public String selectedAccId{get;set;}
public String selectedConId{get;set;}
public List<SelectOption> getAccountNames()
{
List<SelectOption> accOptions= new List<SelectOption>();
accOptions.add( new SelectOption('','--Select--'));
for( Account acc : [select Id,name from Account where name like '[abc]%' limit 5 ] )
{
accOptions.add( new SelectOption(acc.Id,acc.name));
}
return accOptions;
}
public List<SelectOption> getContactNames()
{
List<SelectOption> conOptions= new List<SelectOption>();
List<SelectOption> options = new List<SelectOption>();
if(selectedAccId != null)
{
for( contact con : [select Id,name,accountid from contact where accountid=:selectedAccId ] )
{
conOptions.add( new SelectOption(con.Id,con.name));
}
}
else
{
conOptions.add( new SelectOption('--None--','--None--'));
}
return conOptions;
}
}
Hi,
Did you try above code?
Please mark it as best answer if it helps you.
Thanks,
Abhishek