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

Setting baseUrl for Test Class
Hey all,
I am writing a test class and need to know how to set the baseUrl based on the following method in my controller:
"System.StringException: Starting position out of bounds: -5"
Test Class:
How do I set the baseUrl for my testing here? Do I need to pass a starting URL to the controller? How do I do that?
Thanks!
I am writing a test class and need to know how to set the baseUrl based on the following method in my controller:
public String getBaseUrl(){ vfUrl = Url.getSalesforceBaseUrl().toExternalForm(); Integer iIndex = vfUrl.indexOf('.visual'); instance = vfUrl.substring((iIndex-4),(iIndex)); baseUrl = 'https://'+instance+'.salesforce.com'; return baseUrl; }This method is built to convert the VF page url it begins with into the simple instance URL. However, when I run the following test class I get the error:
"System.StringException: Starting position out of bounds: -5"
Test Class:
@isTest private class Five9ScreenPopTest{ @isTest static void testFive9ScreenPop(){ CreateUser cu = new CreateUser(); User u = cu.createUser(); ApexPages.StandardController cont; System.RunAs(u){ String ani = '8005551212'; Test.setCurrentPage(pageRef); Five9ScreenPop f9sp = new Five9ScreenPop(cont); PageReference numCases = f9sp.NumCases(); } } }NumCases() is a method within the Five9ScreenPop class.
How do I set the baseUrl for my testing here? Do I need to pass a starting URL to the controller? How do I do that?
Thanks!
That'll set your vfUrl differently if you are in test mode.
"Compile Error: Variable does not exist: Test.isRunningTest at line 200 column 18"
What variable do I need to create?