Hi Guys,
Today i faced something new about code issue or else we can say code coverage issue (as per salesforce rule minimum 75% needed),
So, Let me tell you about my issue,
The issue is when i tried so much time to get the code coverage of my class more then 75% but i am getting error (like this : Methods defined as TestMethod do not support Web service callouts, test skipped) in production organization.
The same class and same test class i have wrote in sandbox and it was working fine and get me 93% code coverage but when i am doing this same process in production i am getting error (Methods defined as TestMethod do not support Web service callouts, test skipped).
so what is the reason behind this ?
Answer is :
I strongly believe this has to do with getContent() and getContentAsPDF() method. This was a critical update from salesforce which seems to be activiated in your production and not in sandbox so test class work fine in sandbox but not in production. This update basically considers the above two methods as callouts as opposed to regular method before. So the only solution I can think of is try implementing a Mock as opposed to these methods or just apply check of
Public void abc(){
if(!test.isrunningtest()) {
// Your code
}
}
to ensure that these methods are called only in regular context and not in context of test class.
So now you CANNOT directly call that method in your test class context. You will have to either implement a mock or apply the check in original class (not test class).
If anybody have any question about this than let me know in comments..........
1 comment:
I resolved my testclass issue with solution.
Thanks
Post a Comment