Find your content:

Search form

You are here

Test Class for Webservice class

 
Share

I have a Webservice class :

global with sharing class MyWebServiceClass{

    WebService static Id[] methodVisibility(Id[] ids,String objectName) {

        String test = 'select id from '+objectName+' where '+objectName+'.Id IN :ids';
        List<sObject> resultObjects = Database.query(test);
        List<Id> returnIds = new List<Id>();


        for(sObject obj:resultObjects){
            returnIds.add(obj.Id);

        }
        return returnIds;
    }    
}

I have wriiten a Test Class for this :

@isTest
private class testMyWebService
{

  static List<Id> idList = new List<Id>();
  static List<Account> accList;


   static testMethod void testMethodVisibility() {

       accList = new List<Account>();

       accList.add(new Account(
          Name='testAccount1'
       ));

       accList.add(new Account(
          Name='testAccount2'

       ));

       insert accList ;

       for(Account a : accList) {
          idList.add(a.id);
       }

       MyWebServiceClass.methodVisibility(idList, 'Account');  

   }

}

I am getting 100% code coverage. But I am getting following error

Could not run tests on class 01p90000004VGkc: Line 58, column 25: Illegal assignment from Integer to String

So, I am confised, whether is there anything wrong in my Test methods or code is perfect ?


Attribution to: SFDC Geek
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33871

My Block Status

My Block Content