-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Coverage #9
Comments
Sorry for the late reply. I've not written any tests, it would be quite an undertaking to cover and mock all the XML requests and responses needed to coverage this API. What others have done is commented out the bits their own tests (for controller methods etc) are not needing. If you need some more help on covering the bits remaining I can add some extra notes to the readme if you like. Let me know. |
thanks Andrew for the response. I managed to write the test case covering it up. Thanks for all your help though. |
To cover web service callouts we can use the WebServiceMock interface and the Test.setMock method which are built-in in Apex. following URL will be useful for it. http://salesforce-evershine-knowledge.blogspot.in/2012/10/testing-web-service-callouts.html For my case the doInvoke() method in implementation for WebServiceMock, just returns null. |
Thanks :) |
Thank you so much. I am able to make wrapper class over Metadata API and manage custom objects and fields with ease. |
I am struck with packaging, because I could get only 20% coverage in for metadata service class. My wrapper class got 90%. Can any one help me if they have any code to test coverage MetadataService. |
You could undertake multiple options to increase the test coverage
To cover web service callouts (for the functions such as retrieve/updateMetadata etc. under the MetadataPort class) you can use the WebServiceMock interface and the Test.setMock method which are built-in in Apex. Following URL will be useful for it. http://salesforce-evershine-knowledge.blogspot.in/2012/10/testing-web-service-callouts.html Hope that helps. |
Good advice @vipulpahwa, @cbrao does this help you? |
I tried the above two ways...but not successful. I tried WebServiceMock interface callouts. But it is covering only mock class not Metadata service. Any example code with updateMetadata method will be highly appreciated. |
I've now managed to get 100% coverage for the MetadataService.cls via MetadataServiceTest.cls, please refresh both of these and you should be all set. BTW, this took me quite a few hours to get to the bottom, since there is in fact a platform bug with only covering inner classes in tests, I'm going to raise this. However with a small workaround (which I've included in the above files) it is working. The workaround will also be fine to retain once Salesforce fix the problem, so you should be good to go! Sorry for the issues. |
Thank you so much..it worked like a charm |
Hi Andy,
First of all - thank you for such a great resource on using the metadata api. I have tried playing around with it and got some satisfying results. Just wanted to ask if you managed to write any test cases for the classes? I have been struggling to do so and any help will be hugely appreciated.
Regards
Vipul
The text was updated successfully, but these errors were encountered: