You need to sign in to do that
Don't have an account?
Test class for controller class
With below test class only 45% coverage is showing.can one provide suggetions to get 80%
Test Class
@isTest
public class AssignmentFourTest{
static testMethod void test(){
AssignmentFour vrb = new AssignmentFour ();
vrb.doSearch();
List<account> gacc = vrb.getAccounts();
account acc = new account(name='test account 32',BillingState = 'UK',Phone = '96589658',Website = 'abc@abc.com');
insert acc;
}
}
Controller class
public class AssignmentFour {
//Declear Variables
List<Account> accounts{get;set;}
public String searchString { get; set; }
public List<Account> getAccounts() {
return accounts;
}
//Logic to search the account and display in output panel in VF page
public PageReference doSearch() {
if(searchString !='' && searchString !=null){
accounts = new list<account>();
accounts = [Select Id,Name,BillingState,Phone,Website FROM Account where name =:searchString];
//System.debug('@@@@@@@@@@searchString'+searchString);
}
if(accounts.size()>0 && accounts.size()!= null){
// System.debug('@@@@@@listAccount.size()'+listAccount.size());
}
else{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));
}
return NULL;
}
}
Hi
Have your test give your controller something to search and find:
This should get you there.
Regards
MellowRen
All Answers
Hi
Have your test give your controller something to search and find:
This should get you there.
Regards
MellowRen
Thanks alot MellowRen.....For your solution...