You need to sign in to do that
Don't have an account?
sohail najmi
unit test class for getter setter return method apex salesforce
I am new to salesforce and writing unit-test for ServiceParameters class.
I have tried to get coverage from AccountName method but faild.
Following are the Method:
public without sharing class ServiceParameters {
public Id OrderId {get;set;}
public Id PackageTypeId{ get; set; }
public Id ShipperId{ get; set; }
public Id ShipFromId{ get; set; }
---
---
--
public Custom_Object_c ShipFromAddress {set;get;}
public Custom_Object_c ShipperAddress {set;get;}
public Order CurrentOrder {get;set;}
public Account AccountDetail {set;get;}
public String AccountName {
get {
return this.AccountDetail != null && String.isNotEmpty(this.AccountDetail.Name) ? this.AccountDetail.Name : '';
}
}
public String AccountPhoneNo {
get {
return this.AccountDetail != null && String.isNotEmpty(this.AccountDetail.Phone) ? this.AccountDetail.Phone : '';
}
}
public String ShipFromPhoneNo {
get {
return this.ShipFromAddress != null && String.isNotEmpty(this.ShipFromAddress.ShipGuruApp__Phone_Number__c) ? this.ShipFromAddress.ShipGuruApp__Phone_Number__c : '';
}
}
public String ShipperName {
get {
return this.ShipperAddress != null && String.isNotEmpty(this.ShipperAddress.Name) ? this.ShipperAddress.Name : '';
}
}
.................. ...................................................
So far i have done.
@isTest
private class ServiceParametersTest {
@isTest static void testServiceParametersTest() {
ServiceParameters SP = new ServiceParameters();.
Account AccountDetail = new Account(Name = 'john');
String Namess = SP.AccountName(AccountDetail.Name); // showing error message (Method does not exist or incorrect signature: void AccountName(String) )
How to start the unit test ....
If anyone helps ... THanks in Advance...
I have tried to get coverage from AccountName method but faild.
Following are the Method:
public without sharing class ServiceParameters {
public Id OrderId {get;set;}
public Id PackageTypeId{ get; set; }
public Id ShipperId{ get; set; }
public Id ShipFromId{ get; set; }
---
---
--
public Custom_Object_c ShipFromAddress {set;get;}
public Custom_Object_c ShipperAddress {set;get;}
public Order CurrentOrder {get;set;}
public Account AccountDetail {set;get;}
public String AccountName {
get {
return this.AccountDetail != null && String.isNotEmpty(this.AccountDetail.Name) ? this.AccountDetail.Name : '';
}
}
public String AccountPhoneNo {
get {
return this.AccountDetail != null && String.isNotEmpty(this.AccountDetail.Phone) ? this.AccountDetail.Phone : '';
}
}
public String ShipFromPhoneNo {
get {
return this.ShipFromAddress != null && String.isNotEmpty(this.ShipFromAddress.ShipGuruApp__Phone_Number__c) ? this.ShipFromAddress.ShipGuruApp__Phone_Number__c : '';
}
}
public String ShipperName {
get {
return this.ShipperAddress != null && String.isNotEmpty(this.ShipperAddress.Name) ? this.ShipperAddress.Name : '';
}
}
.................. ...................................................
So far i have done.
@isTest
private class ServiceParametersTest {
@isTest static void testServiceParametersTest() {
ServiceParameters SP = new ServiceParameters();.
Account AccountDetail = new Account(Name = 'john');
String Namess = SP.AccountName(AccountDetail.Name); // showing error message (Method does not exist or incorrect signature: void AccountName(String) )
How to start the unit test ....
If anyone helps ... THanks in Advance...
Hi Please find the solution.
Please let me know it is working or not.
Please mark it as the Best If it helps you
Thank You