+ Start a Discussion
fiona gentryfiona gentry 

Need a test class for Lookup class

Hi Gurus,

Please provide me a test class for below look up class
* Class used to serialize a single Lookup search result item
* The Lookup controller returns a List<LookupSearchResult> when sending search result back to Lightning
public class LookupSearchResult {

    private Id id;
    private String sObjectType;
    private String icon;
    private String title;
    private String subtitle;

    public LookupSearchResult(Id id, String sObjectType, String icon, String title, String subtitle) {
        this.id = id;
        this.sObjectType = sObjectType;
        this.icon = icon;
        this.title = title;
        this.subtitle = subtitle;

    public Id getId() {
        return id;

    public String getSObjectType() {
        return sObjectType;

    public String getIcon() {
        return icon;

    public String getTitle() {
        return title;

    public String getSubtitle() {
        return subtitle;

Best Answer chosen by fiona gentry
Hi Fiona,

Here we go
public class TestLookupSearchResult {
    public static  testMethod void testCallClass(){
		Account acc = new Account(Name='Test Account');
        insert acc;
        LookupSearchResult lcr = new LookupSearchResult(acc.id,'Account','Test Icon','Test Title','Test Sub-Title');
        system.assert(lcr.getId() == acc.id);
        system.assert(lcr.getSObjectType() == 'Account');
        system.assert(lcr.getIcon() == 'Test Icon');
        system.assert(lcr.getTitle() == 'Test Title'); 
        system.assert(lcr.getSubtitle() == 'Test Sub-Title'); 

Gulshan Raj