function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
adisunadisun 

Testing Auth.SessionManagement.getCurrentSession() fails

Hello

A newbie trying to test an apex which is using the  Auth.SessionManagement.getCurrentSession(). 
When I invoke the method  global Process.PluginResult invoke(Process.PluginRequest request)
from my test class using plugin.invoke(request), the test fails with "System.UnexpectedException: Current session unavailable"

Question is: How to test a method which has an internal call to Auth.SessionManagement.getCurrentSession()

I do not find a way to set the session using the API. Any help is appreciated!

Best Answer chosen by adisun
adisunadisun
Used   if(!Test.isRunningTest())  to stop that statement being executed! Worked  as expected!