You need to sign in to do that
Don't have an account?
rksfdc
TestMethods, Eclipse, & SFDC UI (Urgent)
Hi,
I have created a testmethod that simply creates a new opportunity, my issue is if I run the testmethod through Eclipse I am getting System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException. But if I run the same testmethod through SFDC UI I don't get this error message, has anyone faced this issue before? Any help is really appreciated, I have inserted the source code for your reference.
Thanks again,
RK
I have created a testmethod that simply creates a new opportunity, my issue is if I run the testmethod through Eclipse I am getting System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException. But if I run the same testmethod through SFDC UI I don't get this error message, has anyone faced this issue before? Any help is really appreciated, I have inserted the source code for your reference.
Code:
@isTest private class InitOppLineItemTest { static testMethod void myUnitTest() { Account existingAccount = [select Id, name from Account limit 1]; RecordType existingRecordType = [Select r.SobjectType, r.NamespacePrefix, r.Name, r.IsActive, r.Id, r.DeveloperName, r.Description From RecordType r where SobjectType = 'Opportunity' limit 1]; User user = [Select u.Id From User u where u.IsActive = true limit 1]; Opportunity opp = new Opportunity(); opp.recordTypeId = existingRecordType.id; opp.name=existingAccount.name + ': ' + 'TestOpp'; opp.end_date__c = Date.today().addDays(31); opp.CONSOLE_2_Schedule_Start_Date__c = Date.today(); opp.closeDate = Date.today().addDays(31); opp.Amount_Digital__c = 300000; opp.Business_Unit__c = 'ALL01'; opp.stageName = 'Engaged'; opp.AccountId = existingAccount.id; opp.OwnerId = user.id; opp.CurrencyISOCode = 'USD'; insert opp; // System.assert(false); } }
RK
A better practice would be to create a new user, new account and new opportunity, then you are sure it will all work. Just make sure the user you create has a profile and role consistent with your use case for the code. Remember, these objects don't actually get stored in the database, they are only there for the test.
~thanks
You could also try adding system.debug statements to see if something isn't returning properly. Run this version with Eclipse, and if you don't see where the issue is, post the entire debug log.
Eclipse
Salesforce UI