+ Start a Discussion
Soundar Raj PonpandiSoundar Raj 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 Raj 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 Raj PonpandiSoundar Raj Ponpandi
Dear Alain Cabon,

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

Regards,
soundar