0
@isTest
public class TestCreateOppExtension  {
static testMethod void TestCreateOppExtension() {

     Account testAcct = new Account (Name = 'My Test Account');
     insert testAcct;
 Opportunity opp  = new Opportunity(Name ='sample Opp',
                            AccountID = testAcct.ID,
                            Type ='Medium',
                         //   Start_Date__c =System.today(),
                            CloseDate = '2017-08-07',
                            PM_I_Business_Field__c ='Leading Edge East',
                            Main_Group_GPH1__c ='BARC',
                            Customer_Group_ERP__c='Samsung',
                            Device__c='SAMSUNG LOGIC',
                            Node_Size__c='46nm',           
                            StageName = 'M0: Conception',
                            Status__c='Open',
                            Reason_PM_I__c='Quality',          
                            Sub_Reason__c='Superior Material to Competitors',
                            Probability ='10',
                            Monthly_Progress__c='Green'            
                            );

  insert  opp ;

  System.assertEquals(opp .StageName, 'M0: Conception');
  System.assertEquals(opp .Name, 'sample Opp');
  System.assertEquals(opp .Type, 'Medium');
 // System.assertEquals(opp .Start_Date__c ,'2017-07-25');
  System.assertEquals(opp .CloseDate,'2017-08-07');
  System.assertEquals(opp .Customer_Group_ERP__c, 'Samsung');
  System.assertEquals(opp .Device__c, 'SAMSUNG LOGIC');
  System.assertEquals(opp .Node_Size__c, '46nm');
  System.assertEquals(opp .PM_I_Business_Field__c, 'Leading Edge East');
  System.assertEquals(opp .Reason_PM_I__c, 'Quality');
  System.assertEquals(opp .Sub_Reason__c, 'Superior Material to Competitors'); 
 System.assertEquals(opp .Probability,'10%');
  System.assertEquals(opp .Monthly_Progress__c, 'Green');   

}
}

I am getting the below errors:

Invalid initial expression type for field Opportunity.Probability, expecting: Decimal' and 'Invalid initial expression type for field Opportunity.CloseDate, expecting: Date'.

  • 1
    you are assigning all the fields as string values. you should set the values with the corresponding data types.. – Vamsi Krishna Jul 25 '17 at 8:30
0

You are assigning different value to different datatype. Closedate is date type and you are assigning string. And Probability is decimal type and you assigning string.

Replace your lines with this accordingly :

CloseDate = date.valueOf( '2017-08-07' ) Probability = 10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.