You need to sign in to do that
Don't have an account?
Anu-SFDC
How to cover the test coverage for getURL method
Hi
I have a step in the code.
public String custom{get;set;}
public void GlobalController(){
custom = ApexPages.currentPage().getURL();
}
How to write the test coverage for this getURL() method???
Thanks
Anu
It appears that this would work:
There's no reason to actually assert against system library code, because if it doesn't work, there's not much you can do about it. The only code you need to cover is code that you are writing. For example, if you do something with the string custom, then you would want to validate that it is being used correctly.
The only reason to even test the GlobalController function at all is for code coverage. Now, there are system calls that can fail (queries that exceed limits, callouts that fail to connect, etc). In those cases, use the recommended error detection approach (either a try-catch or if-then type detection), and then write a test that simulates failure and success.