You need to sign in to do that
Don't have an account?
XIO
Line -1 Expression cannot be assigned
Hello Developers,
I have the test class below that is receiving this error: "Line -1 Expression cannot be assigned"
Your assistance is greatly appreciated!
I have the test class below that is receiving this error: "Line -1 Expression cannot be assigned"
Your assistance is greatly appreciated!
@isTest public class testClassSuccessPlan { static testMethod void test() { //Create success plan record test.startTest(); Success_Plan__c Success_Plan = new Success_Plan__c(); Success_Plan__c.Name = 'Test Plan'; Success_Plan__c.Account__c = '0015000000SsYnN'; Success_Plan__c.Member_Success_Manager__c = '00550000006Rkqu'; insert Success_Plan; //Create initiative record Initiatives__c Initiative = new Initiatives__c(); Initiatives__c.Name = 'Test Int'; Initiatives__c.Service_Discipline__c = 'a035000000BdWzV'; insert Initiative; test.stopTest(); } }
Seems like you are new to Apex Development No issue you are missing incorrect object name in your code.
Please find the updated code below and let me know if this helps yo.
Thanks,
Lokesh
You have written these two lines ,
Success_Plan__c.Account__c = '0015000000SsYnN';
Success_Plan__c.Member_Success_Manager__c = '00550000006Rkqu';
Here, test class cannot find these two ids as test class only deals with those reccords which have been created inside the test class asa test data. you have not created neither the account or the succes Manager in sidde the test class.
So, actually there is two option,
- Create an Account like,
- Put isTest(seeAlldata = true) instead of isTest (Not a best practise at all)
Thanks & Regards,and do the same for success manager. I am seeing Succes Manager is for Users. So, for these first SOQL the proper Profile and create a user like this, Please do the same thing for Service Disipline also.
Prosenjit.
@isTest(SeeAllData=true) from this annotation is used to open up data access when applied at the class or method level. with the isTest(SeeAllData=true) annotation. In this case, the method will still have access to all the data in the organization.
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.
You are using hard cord ids in your test class.acutely it is not the best practic but @isTest(SeeAllData=true) you can fetch all org data.
Thanks,
Harshit Garg
harshitgarg2591@gmail.com