Ok in that case let me tell you you can not make a webservice call out from a est method and test method will fail if you do so. You need to make a chaneg in your contrller
Change this
public List<VocalcomComToolsadmin.CampaignOutbound> listActiveCampaigns {
get {
if(listActiveCampaigns == null)
listActiveCampaigns = new VocalcomComToolsadmin.ReadToolsSoap().ListActiveCampaign('1').CampaignOutbound;
return listActiveCampaigns;
}
private set;
}
to
public List<VocalcomComToolsadmin.CampaignOutbound> listActiveCampaigns {
get {
if(listActiveCampaigns == null)
if(!Test.isRunningTest())
{
listActiveCampaigns = new VocalcomComToolsadmin.ReadToolsSoap().ListActiveCampaign('1').CampaignOutbound;
}
else
{
listActiveCampaigns = new List<VocalcomComToolsadmin.CampaignOutbound>();
//You can create a dummy response similar to what your webservice might have returned
}
return listActiveCampaigns;
}
private set;
}
Could you please help to write a dummy response similar to what the webservice might have returned ? I have imported the WSDL, and the proxy created some classes that implements the SOAP message. The method that i'm using from the controller is "ListActiveCampaign" -->
listActiveCampaigns = new VocalcomComToolsadmin.ReadToolsSoap().ListActiveCampaign('1').CampaignOutbound;
Do i need to create a dummy response, or with 79% code coverage, it's sufficient ?
I have just created a new topic "APEX - CallCenter - Parse XML File ". In my controller, i would like to get the CustomerId from the CallCenter configuration file. Currently, i pass this parameter as static value : 1. Could you, please help ?
try this I hope it will cover your catch block, I set OwnerId to null so that it give exception
And this Code will never get covered
listActiveCampaigns = new VocalcomComToolsadmin.ReadToolsSoap().ListActiveCampaign('1').CampaignOutbound
because web servoce call out are not covered in testMethod
Let me know if any issues
All Answers
try this, It should improve your code coverage
Ok in that case let me tell you you can not make a webservice call out from a est method and test method will fail if you do so. You need to make a chaneg in your contrller
Change this
to
and try with test method from last post
Now it's better, code coverage is 79%.
Could you please help to write a dummy response similar to what the webservice might have returned ? I have imported the WSDL, and the proxy created some classes that implements the SOAP message. The method that i'm using from the controller is "ListActiveCampaign" -->
listActiveCampaigns = new VocalcomComToolsadmin.ReadToolsSoap().ListActiveCampaign('1').CampaignOutbound;
Do i need to create a dummy response, or with 79% code coverage, it's sufficient ?
All the best,
Yes I can but I think you need that to increase coverage,the code that is not covered must be the catch block , to do so add this method as well
Try with this, add this one more test method , this should increase you code coverage by covering catch block as well
try with this
change this in your controller
to
So that it catches all kind of exception.
No more error, however still covering 79%. It indicates that the catch is not covered.
try this I hope it will cover your catch block, I set OwnerId to null so that it give exception
And this Code will never get covered
listActiveCampaigns = new VocalcomComToolsadmin.ReadToolsSoap().ListActiveCampaign('1').CampaignOutbound
because web servoce call out are not covered in testMethod
Let me know if any issues
95% code coverage.
A lot of thanks for help.
All the best.
Your welcome mate
I have just created a new topic "APEX - CallCenter - Parse XML File ". In my controller, i would like to get the CustomerId from the CallCenter configuration file. Currently, i pass this parameter as static value : 1. Could you, please help ?
All the best.