You need to sign in to do that
Don't have an account?
SFDC_coder
I got this compile error yesterday but not today: variable result is used before it is declared
Code snippet:
static testMethod void testOptyTrigger2() {
List<Id> newWorkItemIds;
User u = [select id, Firstname, Alias, Email, Username, LastName, CommunityNickname, TimeZoneSidKey,
LocaleSidKey, EmailEncodingKey, LanguageLocaleKey from User where Username='User1@marvell.com'];
User u2 = [select id, Firstname, Alias, Email, Username, LastName, CommunityNickname, TimeZoneSidKey,
LocaleSidKey, EmailEncodingKey, LanguageLocaleKey from User where Username='User2@marvell.com'];
System.runAs(u){
Opportunity testOpty = [select id from Opportunity where name ='TestOpty'];
}
got this error when i am in System.runAs line. Please let me know the exact way to solve this error..
Thanks in advance.
static testMethod void testOptyTrigger2() {
List<Id> newWorkItemIds;
User u = [select id, Firstname, Alias, Email, Username, LastName, CommunityNickname, TimeZoneSidKey,
LocaleSidKey, EmailEncodingKey, LanguageLocaleKey from User where Username='User1@marvell.com'];
User u2 = [select id, Firstname, Alias, Email, Username, LastName, CommunityNickname, TimeZoneSidKey,
LocaleSidKey, EmailEncodingKey, LanguageLocaleKey from User where Username='User2@marvell.com'];
System.runAs(u){
Opportunity testOpty = [select id from Opportunity where name ='TestOpty'];
}
got this error when i am in System.runAs line. Please let me know the exact way to solve this error..
Thanks in advance.
Apex is trying to use the variable you are declaring instead of referencing the class. To Apex, result and Result are the same things, and at the moment result is closest in scope. Try renaming it to r or resultA or whatever makes the most sense for your code.
Note: Apex is case insensitive
- https://developer.salesforce.com/page/Apex_Code:_The_Basics#Case_Sensitivity
Hope this helps.Thanks,
Nagendra.
To query org data in testclass use SeeAllData = true in test class.
else insert new user like below.
Thanks
Varaprasad
system.runas(u1){
-==========
======
}