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
Soundar Rajan PonpandiSoundar Rajan Ponpandi 

how to cover a test class for this sample code ?

Hi,

Can anyone please help how to cover a test class for this code ?
 
public class GD_CartProductsWrapper {

    @AuraEnabled
    public GD_Cart__c cartItem;
    
    @AuraEnabled
    public List<String> uomPicklist;
    
    @AuraEnabled
    public Map<String,GD_Cart__c> orderLinesByUom;
    
    @AuraEnabled
    public Decimal unitPrice;
    
    @AuraEnabled
    public Decimal totalPrice;
    
    public GD_CartProductsWrapper(){
        cartItem = new GD_Cart__c();
        uomPicklist = new List<String>();
        orderLinesByUom = new Map<String,GD_Cart__c>();
        totalPrice = 0;
    }
}

Regards,
Soundar.​​​​​​​
Best Answer chosen by Soundar Rajan Ponpandi
Alain CabonAlain Cabon
There is just a constructor (new).
 
@isTest
private class GD_CartProductsWrapperTest {
    @isTest static void testconstructor() {
        GD_CartProductsWrapper cart = new GD_CartProductsWrapper();
        System.assertEquals(0,cart.totalPrice);
    }
}

 

All Answers

Alain CabonAlain Cabon
There is just a constructor (new).
 
@isTest
private class GD_CartProductsWrapperTest {
    @isTest static void testconstructor() {
        GD_CartProductsWrapper cart = new GD_CartProductsWrapper();
        System.assertEquals(0,cart.totalPrice);
    }
}

 
This was selected as the best answer
Soundar Rajan PonpandiSoundar Rajan Ponpandi
Dear Alain Cabon,

Thanks for your help! (code coverage = 100%)

Regards,
soundar