+ Start a Discussion
sachitanand kumarsachitanand kumar 

when i deploy test class in Inbound Change Sets i got error Invalid type: OpportunityOwnerUpdate at line 16 column 42 in my test code and I don't understand why and how to fix. Below is my test code:

  1. @isTest
  2. public class OpportunityOwnerUpdate_test {
  3.     
  4.     static testMethod void data1(){
  5.         List<Opportunity> Opportunitys = new List<Opportunity>();
  6.         Opportunity a = New Opportunity();
  7.         a.Name = 'myOpportunity';
  8.         a.StageName='Stage 1 - Expressed Interest';
  9.         a.CloseDate=date.today();
  10.         Opportunitys.add(a);
  11.         insert Opportunitys;
  12.          
  13.     
  14.         ApexPages.StandardSetController  sac = new ApexPages.StandardSetController (Opportunitys);
  15.         sac.setSelected([SELECT Id, OwnerId FROM Opportunity LIMIT 2]);
  16.         OpportunityOwnerUpdate aop = new OpportunityOwnerUpdate(sac);
  17.         aop.isSelected = true;
  18.         
  19.       
  20.      aop.updateOpportunity();
  21.              
  22.     }
  23.     
  24.    static testMethod void data2(){
  25.         List<Opportunity> Opportunitys = new List<Opportunity>();
  26.         Opportunity a = New Opportunity();
  27.         a.Name = 'myOpportunity';
  28.         a.StageName='Stage 1 - Expressed Interest';
  29.         a.CloseDate=date.today();
  30.         Opportunitys.add(a);
  31.         insert Opportunitys;
  32.          
  33.     
  34.         ApexPages.StandardSetController  sac = new ApexPages.StandardSetController (Opportunitys);
  35.         OpportunityOwnerUpdate aop = new OpportunityOwnerUpdate(sac);
  36.         aop.isSelected = false;
  37.     }
  38. }
Best Answer chosen by sachitanand kumar
Arvind KumarArvind Kumar
Hi Kumar,

OpportunityOwnerUpdate your Controller class. Are you adding your controller class in change set? If not, please add your test class in change set.

Thanks

All Answers

Arvind KumarArvind Kumar
Hi Kumar,

OpportunityOwnerUpdate your Controller class. Are you adding your controller class in change set? If not, please add your test class in change set.

Thanks
This was selected as the best answer
Charan Thumma 15Charan Thumma 15
Hi Kumar,

I think you are updating the opportunity owner in ctonroller. Please make sure the opportunity owner is valid user ID and change the test class(Add runas method) to create opportunity with correct owner. 
James LoghryJames Loghry
Hi Kumar, when you paste code to the developer boards, please use the code format button (< >).  By doing so, you won't need to include the line numbers in your example.  Thanks!