You need to sign in to do that
Don't have an account?
sreekanth reddy
Test Class For below code.
Hi All,
How to write test class for below class.pls help me
public class searchres2
{
public String selectedvalue { get; set; }
public string country{get;set;}
public string TypeOfProgram{get;set;}
public string CourseSepcialisation1{get;set;}
public string CourseCategory3{get;set;}
public list<University_Database__c> bank{get;set;}
Public University_Database__c ban{get;set;}
public id sh;
public void login()
{
bank = [select id,Country1__c,TypeOfProgram__c,Course_Sepcialisation1__c,Course_Category__c from University_Database__c where Country1__c=:country
and TypeOfProgram__c=:TypeOfProgram and Course_Category__c=:CourseCategory3 and Course_Sepcialisation1__c=:CourseSepcialisation1 LIMIT 1000];
}
public String getSelected_value()
{
return null;
}
public List<SelectOption> getcountryOptions()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new selectOption('None','--- None ---'));
Schema.DescribeFieldResult fieldResult = University_Database__c.Country1__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return options;
}
public List<SelectOption> getTypeOfProgramOptions()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new selectOption('None','--- None ---'));
Schema.DescribeFieldResult fieldResult = University_Database__c.TypeOfProgram__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return options;
}
public List<SelectOption> getCourseCategory3Options()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new selectOption('None','--- None ---'));
Schema.DescribeFieldResult fieldResult = University_Database__c.Course_Category__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return options;
}
}
How to write test class for below class.pls help me
public class searchres2
{
public String selectedvalue { get; set; }
public string country{get;set;}
public string TypeOfProgram{get;set;}
public string CourseSepcialisation1{get;set;}
public string CourseCategory3{get;set;}
public list<University_Database__c> bank{get;set;}
Public University_Database__c ban{get;set;}
public id sh;
public void login()
{
bank = [select id,Country1__c,TypeOfProgram__c,Course_Sepcialisation1__c,Course_Category__c from University_Database__c where Country1__c=:country
and TypeOfProgram__c=:TypeOfProgram and Course_Category__c=:CourseCategory3 and Course_Sepcialisation1__c=:CourseSepcialisation1 LIMIT 1000];
}
public String getSelected_value()
{
return null;
}
public List<SelectOption> getcountryOptions()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new selectOption('None','--- None ---'));
Schema.DescribeFieldResult fieldResult = University_Database__c.Country1__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return options;
}
public List<SelectOption> getTypeOfProgramOptions()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new selectOption('None','--- None ---'));
Schema.DescribeFieldResult fieldResult = University_Database__c.TypeOfProgram__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return options;
}
public List<SelectOption> getCourseCategory3Options()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new selectOption('None','--- None ---'));
Schema.DescribeFieldResult fieldResult = University_Database__c.Course_Category__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return options;
}
}
You can simply insert the records for University_Database__c with the conditions which you have mentioned and then you can call other methods , it will cover the class for you...if you have already startted with test class then share teh code so I can help you to increase the coverage...
Thanks,
Sandeep