Comments (11)
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.
from apex-mdapi.
thanks Andrew for the response. I managed to write the test case covering it up. Thanks for all your help though.
from apex-mdapi.
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.
from apex-mdapi.
Thanks :)
from apex-mdapi.
Thank you so much. I am able to make wrapper class over Metadata API and manage custom objects and fields with ease.
from apex-mdapi.
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.
from apex-mdapi.
You could undertake multiple options to increase the test coverage
- You could comment out the sub-classes / code which you do not require thereby reducing the size of the executable code and writing test cases for only code that is required in your code.
- If you do not want to comment out, since 95% of the code is just sub classes - you could just instantiate an object of each class which would cover up the code for that class.
example - MetadataService.CustomObject object = new MetadataService.CustomObject();
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.
from apex-mdapi.
Good advice @vipulpahwa, @cbrao does this help you?
from apex-mdapi.
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.
from apex-mdapi.
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.
from apex-mdapi.
Thank you so much..it worked like a charm
from apex-mdapi.
Related Issues (20)
- Help article to use named credentials with wrapper has been removed HOT 1
- Generate an Apex from WSDL
- GlobalValueSetTranslation HOT 2
- Update search layout task, event, activity HOT 1
- System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element customizeSetup
- Apex Wrapper Metadata API Takes Time to Reflect the Change
- Can't create in production org
- Can't create a sharing rule HOT 2
- GlobalValueSetTranslation
- Can we create ApexClass natively? Any Example? HOT 1
- UserInfo.getSessionId() makes this unusable in packaged code HOT 2
- How do we update multiple profiles at once?
- LightningComponentBundle (LWC): reading/creating/updating
- Creating Apex Trigger
- Creating a MultiPicklist HOT 2
- System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element includeRecordsOwnedByAll
- How To get Picklist Value according to record type for a custom object HOT 3
- Can anyone suggest on how to read the flexipage? HOT 7
- Issue retrieving layout metadata for object via Metadata API HOT 1
- Row Lock Error - Updating the Picklist values in the Customer field and RecordTypes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apex-mdapi.