You need to sign in to do that
Don't have an account?
S Sai
how Write Test class
HI how to write test class for this class
public class CountryAccountRelatedContacts {
public id tobeEdited{get; set;}
public String selectedcouId{get;set;}
public String selectedAccId{get;set;}
public string conid{get;set;}
public boolean showPopup{ get; set; }
public boolean isDownload {get;set;}
public list<contact> lstcontact{get;set;}
public PageReference Download(){
isDownload = true;
return null;
}
public List<SelectOption> getCountryNames() {
List<SelectOption> couOptions= new List<SelectOption>();
couOptions.add( new SelectOption('','--Select--'));
list<Country__c> cut = [select Id,name from Country__c];
for( Country__c cou : cut ) {
couOptions.add( new SelectOption(cou.Id,cou.name));
}
return couOptions;
}
public List<SelectOption> getAccountNames() {
system.debug('country ID'+selectedcouid);
List<SelectOption> accOptions= new List<SelectOption>();
List<SelectOption> options = new List<SelectOption>();
if(selectedcouId != null){
list<account> act = [select Id,name,Country__c from account where Country__c=:selectedcouId order by name ASC ];
for( Account acc : act ) {
accOptions.add( new SelectOption(acc.Id,acc.name));
}
}
else
{
accOptions.add( new SelectOption('--None--','--None--'));
}
return accOptions;
}
public pagereference Submit(){
lstcontact= new List<contact>();
lstcontact= [SELECT ID,name, Firstname,lastname,email,phone,account.name from contact WHERE accountId=:selectedaccid order by name ASC];
return null;
}
public PageReference openpopup() {
showPopup =true;
return null;
}
public PageReference cancel() {
showPopup =false;
return null;
}
public PageReference DeleteCon() {
List<contact> con = [select id,name,Phone,accountid from contact where Id= :conid];
delete con;
showPopup =false;
// contacts =new List<contact>();
return null;
}
public String getTobeEdited() {
return null;
}
public PageReference Editable() {
return null;
}
public void saveRecord(){
Contact tobeupdated;
for(Contact temp : lstcontact){
if(temp.id==tobeEdited){
tobeupdated = temp;
break;
}
}
update tobeupdated;
tobeEdited = null;
}
}
Thanks
SS
public class CountryAccountRelatedContacts {
public id tobeEdited{get; set;}
public String selectedcouId{get;set;}
public String selectedAccId{get;set;}
public string conid{get;set;}
public boolean showPopup{ get; set; }
public boolean isDownload {get;set;}
public list<contact> lstcontact{get;set;}
public PageReference Download(){
isDownload = true;
return null;
}
public List<SelectOption> getCountryNames() {
List<SelectOption> couOptions= new List<SelectOption>();
couOptions.add( new SelectOption('','--Select--'));
list<Country__c> cut = [select Id,name from Country__c];
for( Country__c cou : cut ) {
couOptions.add( new SelectOption(cou.Id,cou.name));
}
return couOptions;
}
public List<SelectOption> getAccountNames() {
system.debug('country ID'+selectedcouid);
List<SelectOption> accOptions= new List<SelectOption>();
List<SelectOption> options = new List<SelectOption>();
if(selectedcouId != null){
list<account> act = [select Id,name,Country__c from account where Country__c=:selectedcouId order by name ASC ];
for( Account acc : act ) {
accOptions.add( new SelectOption(acc.Id,acc.name));
}
}
else
{
accOptions.add( new SelectOption('--None--','--None--'));
}
return accOptions;
}
public pagereference Submit(){
lstcontact= new List<contact>();
lstcontact= [SELECT ID,name, Firstname,lastname,email,phone,account.name from contact WHERE accountId=:selectedaccid order by name ASC];
return null;
}
public PageReference openpopup() {
showPopup =true;
return null;
}
public PageReference cancel() {
showPopup =false;
return null;
}
public PageReference DeleteCon() {
List<contact> con = [select id,name,Phone,accountid from contact where Id= :conid];
delete con;
showPopup =false;
// contacts =new List<contact>();
return null;
}
public String getTobeEdited() {
return null;
}
public PageReference Editable() {
return null;
}
public void saveRecord(){
Contact tobeupdated;
for(Contact temp : lstcontact){
if(temp.id==tobeEdited){
tobeupdated = temp;
break;
}
}
update tobeupdated;
tobeEdited = null;
}
}
Thanks
SS
1) http://amitsalesforce.blogspot.in/search/label/Test%20Class
2) http://amitsalesforce.blogspot.in/2015/06/best-practice-for-test-classes-sample.html
Please try below code Please let us know if this will help you
Thanks for your reply it's throughing error when i am saving like
[Error] Error: Compile Error: Method does not exist or incorrect signature: Test.StartTest() at line 28 column 9
Thanks
SS
Please let us know if this will help you
Its Giveing 0%
Thanks
SS
Not Working
Thanks
SS