Skip to main content
added 84 characters in body
Source Link
Matt and Neil
  • 33.1k
  • 7
  • 107
  • 190

I have a test class containing several WebServiceMock implementors. He looks like this:

@isTest private class MyTestClass {
    
    public class ValidateMock implements WebServiceMock {
        public void doInvoke(Object stub, Object request, Map<String, Object> response, String endpoint, String soapAction, String requestName, String responseNS, String responseName, String responseType) {
            //...
        }
    }
    
    static testMethod void coverRetrieve() {
        Test.setMock(WebServiceMock.class, new ValidateMock());
        //...
        System.assert(result instanceof Object);
    }
}

But as I create more WebServiceMocks, I see the Code Coverage metrics for my org going south!

Of course, I tried to annotate the WebServiceMock inner classes with @isTest but will get:

Only static top-level class methods can be test methods

(Which they should be, anyway, as inner classes of an @IsTest annotated class)

Currently I think my options are:

  1. write a "Test Test" method that invokes all the mocks just to bump the coverage,

  2. proliferate all the WebServiceMock classes as top-level, then add the @isTest annotation,

How else could I prevent these test inner classes being seen by the code coverage metrics?

I have a test class containing several WebServiceMock implementors. He looks like this:

@isTest private class MyTestClass {
    
    public class ValidateMock implements WebServiceMock {
        public void doInvoke(Object stub, Object request, Map<String, Object> response, String endpoint, String soapAction, String requestName, String responseNS, String responseName, String responseType) {
            //...
        }
    }
    
    static testMethod void coverRetrieve() {
        Test.setMock(WebServiceMock.class, new ValidateMock());
        //...
        System.assert(result instanceof Object);
    }
}

But as I create more WebServiceMocks, I see the Code Coverage metrics for my org going south!

Of course, I tried to annotate the WebServiceMock inner classes with @isTest but will get:

Only static top-level class methods can be test methods

Currently I think my options are:

  1. write a "Test Test" method that invokes all the mocks just to bump the coverage,

  2. proliferate all the WebServiceMock classes as top-level, then add the @isTest annotation,

How else could I prevent these test inner classes being seen by the code coverage metrics?

I have a test class containing several WebServiceMock implementors. He looks like this:

@isTest private class MyTestClass {
    
    public class ValidateMock implements WebServiceMock {
        public void doInvoke(Object stub, Object request, Map<String, Object> response, String endpoint, String soapAction, String requestName, String responseNS, String responseName, String responseType) {
            //...
        }
    }
    
    static testMethod void coverRetrieve() {
        Test.setMock(WebServiceMock.class, new ValidateMock());
        //...
        System.assert(result instanceof Object);
    }
}

But as I create more WebServiceMocks, I see the Code Coverage metrics for my org going south!

Of course, I tried to annotate the WebServiceMock inner classes with @isTest but will get:

Only static top-level class methods can be test methods

(Which they should be, anyway, as inner classes of an @IsTest annotated class)

Currently I think my options are:

  1. write a "Test Test" method that invokes all the mocks just to bump the coverage,

  2. proliferate all the WebServiceMock classes as top-level, then add the @isTest annotation,

How else could I prevent these test inner classes being seen by the code coverage metrics?

Source Link
Matt and Neil
  • 33.1k
  • 7
  • 107
  • 190

My test classes are contributing towards uncovered code

I have a test class containing several WebServiceMock implementors. He looks like this:

@isTest private class MyTestClass {
    
    public class ValidateMock implements WebServiceMock {
        public void doInvoke(Object stub, Object request, Map<String, Object> response, String endpoint, String soapAction, String requestName, String responseNS, String responseName, String responseType) {
            //...
        }
    }
    
    static testMethod void coverRetrieve() {
        Test.setMock(WebServiceMock.class, new ValidateMock());
        //...
        System.assert(result instanceof Object);
    }
}

But as I create more WebServiceMocks, I see the Code Coverage metrics for my org going south!

Of course, I tried to annotate the WebServiceMock inner classes with @isTest but will get:

Only static top-level class methods can be test methods

Currently I think my options are:

  1. write a "Test Test" method that invokes all the mocks just to bump the coverage,

  2. proliferate all the WebServiceMock classes as top-level, then add the @isTest annotation,

How else could I prevent these test inner classes being seen by the code coverage metrics?