function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VFVF 

Test method for the following class

How can we write a testcase for this class.

public class test

public class createBasicSegmentResponse {

 

 

   public Long return_x;

 

 

   private String[] return_x_type_info = new String[]{'return','http://www.w3.org/2001/XMLSchema','long','1','1','false'};

 

 

   private String[] apex_schema_type_info = new String[]{'http://salesforce.com/','false','false'};

 

 

   private String[] field_order_type_info = new String[]{'return_x'};

 

 

   }

}

 

Please help me out as i am able to cover the code for normal classes but its getting diffulct to the classes generated from wsdl.

 

 

Thanks.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
wesnoltewesnolte

Hey

 

Sure thing, here's a bit of a sample

 

@isTest

private class testTest{

 

    static testMethod void myUnitTest() {

  Test t = new Test();

Test.createBasicSegmentResponse cbsr = new Test.createBasicSegmentResponse();

 

Long x = csbr.return_x; 

 

}

 

 

You won't be able to test your variables that are marked as private though. Please note I haven't tested the above code but it should help getting you started.

 

Wes 

All Answers

wesnoltewesnolte

Hey

 

Sure thing, here's a bit of a sample

 

@isTest

private class testTest{

 

    static testMethod void myUnitTest() {

  Test t = new Test();

Test.createBasicSegmentResponse cbsr = new Test.createBasicSegmentResponse();

 

Long x = csbr.return_x; 

 

}

 

 

You won't be able to test your variables that are marked as private though. Please note I haven't tested the above code but it should help getting you started.

 

Wes 

This was selected as the best answer
VFVF

canu help me  in writing test class for a method:

 

public class CcmdServicePort {

//public String endpoint_x = 'http://81.92.115.199/apiccmd/services/CcmdService';

 public Map<String,String> inputHttpHeaders_x;

public Map<String,String> outputHttpHeaders_x;

public String clientCert_x;

public String clientCertPasswd_x;

public Integer timeout_x;

private String[] ns_map_type_info = new String[]{'http://api.service.apiccmd.emailvision.com/', 'CCMDAPIV3'};

 public Long createBasicSegment(String token,String name,String describe,String criteria, String endpoint_x) {CCMDAPIV3.createBasicSegment request_x = new CCMDAPIV3.createBasicSegment();

CCMDAPIV3.createBasicSegmentResponse response_x;

request_x.token = token;

request_x.name = name;

request_x.describe = describe;

request_x.criteria = criteria;

Map<String, CCMDAPIV3.createBasicSegmentResponse> response_map_x = new Map<String, CCMDAPIV3.createBasicSegmentResponse>();response_map_x.put('response_x', response_x);

WebServiceCallout.invoke(

this,

request_x,

response_map_x,

new String[]{endpoint_x,

'',

'http://api.service.apiccmd.emailvision.com/',

'createBasicSegment',

'http://api.service.apiccmd.emailvision.com/',

'createBasicSegmentResponse',

'CCMDAPIV3.createBasicSegmentResponse'}

);

response_x = response_map_x.get('response_x'); return response_x.return_x;

}}

}