You need to sign in to do that
Don't have an account?

get ip address test Class
Hi,
I'm trying to test a class wher I get current User Ip
In sandbox it is ok, but in production I receive this error:
System.UnexpectedException: Current session unavailable
Stack Trace: Class.Auth.SessionManagement.getCurrentSession: line 5, column 1 Class.siteLeadForm.GetUserIPAddress: line 18, column 1 Class.siteLeadFormTEST.Test1: line 17, column 1
Any Ideas?
thankyou in advance
I'm trying to test a class wher I get current User Ip
@AuraEnabled public static String GetUserIPAddress() { string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp'); return ReturnValue; } // GetUserIPAddress Test class: public static testmethod void Test1() {System.runAs(new User(Id = UserInfo.getUserId())){ String ip = siteLeadForm.GetUserIPAddress();} }
In sandbox it is ok, but in production I receive this error:
System.UnexpectedException: Current session unavailable
Stack Trace: Class.Auth.SessionManagement.getCurrentSession: line 5, column 1 Class.siteLeadForm.GetUserIPAddress: line 18, column 1 Class.siteLeadFormTEST.Test1: line 17, column 1
Any Ideas?
thankyou in advance
Use this key word in your test class "if(!Test.isRunningTest())"
like above said,
hope this will help
Thanks
karthik
All Answers
Use this key word in your test class "if(!Test.isRunningTest())"
like above said,
hope this will help
Thanks
karthik