• Mosib Khan
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hello,

 

I have such code:

List<Contact> retContacts = [FIND :txtName IN ALL FIELDS RETURNING Contact(Id, Name,Phone,Email)][0];

 

This code works and gives me few results when I am running it through a visualforce page. I need to upload my app for which I require min 75% code coverage, so I wrote test class which has:

mainObj.txtName = 'man*';
mainObj.SearchRecord();

 

It shows me only 57% code coverage and when i see test results I find the coverage is not going inside loop I have to process found results, in other words no results are returned.

 

If I use such statement it works and give perfect code coverage but I dont want to use this statement because it just searches Name field:

queryname = '%' + txtName + '%';

retContacts = [SELECT Id, Name,Phone,Email FROM Contact WHERE Name like :queryname];


Can anybody please help?

 

Thank you,

Nishant

http://nanostuffs.com/