You need to sign in to do that
Don't have an account?
Sdfc dev
Test code coverage
Hi,
pulic void getLoginResult(String username, String password){ mysoap.Soap connection = new mysoap.Soap(); mysoap.LoginResult loginResult = connection.login(username, password); mysoap.SessionHeader_element sessionHeader = new mysoap.SessionHeader_element(); sessionHeader.sessionId = loginResult.sessionId; connection.SessionHeader = sessionHeader; connection.endpoint_x = loginResult.serverUrl; }
mysoap is enterprise wsdl generated from my salesforce org.
How do I get code coverage for the above method?
Thanks in advance
Hi,
This method will cover itself if you have called it somewhere, for which you are writing test class
OR
You can call it easliy write after defining your controller like
yourClassName controller = new yourClassName();
//Assigning value
controller.UserName = 't@sfdc.com'
controller.Password = 'testing';
//Calling method
controller.getLoginResult(userName, password);
Check out this post for test classes basics
http://abhithetechknight.blogspot.in/2013/10/salesforce-test-class-basics.html
Hi,
Thanks for your reply abhi.
I am doing exactly the same as suggested above but it fails in getting sessionId and executes the catch block.
Here it fails "sessionHeader.sessionId = loginResult.sessionId;"
It is because both username and password are dummy ones.
Is there any workaround to resolve this issue in test class?
Thanks in advance