Giter Site home page Giter Site logo

Test Coverage about apex-mdapi HOT 11 CLOSED

certinia avatar certinia commented on July 30, 2024
Test Coverage

from apex-mdapi.

Comments (11)

afawcett avatar afawcett commented on July 30, 2024

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.

vipultaylor avatar vipultaylor commented on July 30, 2024

thanks Andrew for the response. I managed to write the test case covering it up. Thanks for all your help though.

from apex-mdapi.

me-hemantgupta avatar me-hemantgupta commented on July 30, 2024

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.

vipultaylor avatar vipultaylor commented on July 30, 2024

Thanks :)

from apex-mdapi.

cbrao avatar cbrao commented on July 30, 2024

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.

cbrao avatar cbrao commented on July 30, 2024

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.

vipultaylor avatar vipultaylor commented on July 30, 2024

You could undertake multiple options to increase the test coverage

  1. 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.
  2. 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.

afawcett avatar afawcett commented on July 30, 2024

Good advice @vipulpahwa, @cbrao does this help you?

from apex-mdapi.

cbrao avatar cbrao commented on July 30, 2024

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.

afawcett avatar afawcett commented on July 30, 2024

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.

cbrao avatar cbrao commented on July 30, 2024

Thank you so much..it worked like a charm

from apex-mdapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.