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
CHENNA$A@CHENNA$A@ 

Test class Coverage ( Urgent)

Hi All,

 

How i need to cover my code coverage for below code in my class.

 

 public class productDetail {
        public list<string> productCode {get; set;}
        public list<string> productDescription {get;set;}
        public list<string> productName {get; set;}
        public list<string> pricebookName {get; set;}
        public list<string> pricebookId {get; set;}
        public list<string> pricebookPrice {get; set;}
        
        public productDetail (){
            productCode = new list<string>();
            productDescription = new list<string>();
            productName = new list<string>();
            pricebookName = new list<string>();
            pricebookId = new list<string>();
            pricebookPrice = new list<string>();
        }
    }
    
    public class pricebookInfo {
            public list<string> colNames {get; set;}
            public list<string> colModel {get; set;}
            public list<productDetail> products {get; set;}
    }

Best Answer chosen by Admin (Salesforce Developers) 
Prafull G.Prafull G.

Its pretty simple. As you have only Class denination and contrustor so you can instantiate your class in test method and you will be able to cover the code.

Like:
@isTest
private class ProductDetailsTest {

  @isTest

  static void myTest1() {
    ProductDetail pDetail = new ProductDetail();
  }
}

Give it a try.

All Answers

Prafull G.Prafull G.

Its pretty simple. As you have only Class denination and contrustor so you can instantiate your class in test method and you will be able to cover the code.

Like:
@isTest
private class ProductDetailsTest {

  @isTest

  static void myTest1() {
    ProductDetail pDetail = new ProductDetail();
  }
}

Give it a try.

This was selected as the best answer
BALA_RAMBALA_RAM

@IsTest

public static testMethod void testproductDetail ()

{

productDetail  pd=new productDetail();

pd. productDetail ();

}