You need to sign in to do that
Don't have an account?
Shiv Shankar
How to cover a text coverage for property
Hello friends,
1. I am using some properties on my visualforce page, how can i get test coverage for these properties
2. I am setting the system.test.setCurrentPage(My VF Page) but it's not going through property code.
3. i am mentioning code below for which i want test coverage.
public Map<string,Basket__c> productGroupCodeToBasketItem{ get{ try{ if(productGroupCodeToBasketItem == null){ productGroupCodeToBasketItem = new Map<string,Basket__c>(); for(Basket__c rec : [Select id, product__c,Product__r.Name from Basket__c where createdById =: UserInfo.getUserId()]){ productGroupCodeToBasketItem.put(rec.Product__r.Name,rec);//Collectin of all items presetn in basket } } return productGroupCodeToBasketItem; }catch(Exception e){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,e.getMessage())); return null; } } set; } //Current Request for the user public Request__c request{ get{ try{ if(request == null){ List<Request__c> requestList = [SELECT Id,Attention_to__c,Address_1__c,Address_2__c,Shipping_Zip_Postal_Code__c, Shipping_City__c,Shipping_State_Province__c ,Shipping_Country__c, Is_Agree_With_Terms_and_Conditions__c FROM Request__c WHERE CreatedById =: UserInfo.getUserId() AND Status__c = 'In Progress']; if(! requestList.isEmpty()){ request = new Request__c(); request = requestList.get(0); } if(request != null){ request.Shipping_Zip_Postal_Code__c = acc.Shipping_Zip_Postal_Code__c; request.Shipping_City__c = acc.Shipping_City__c; request.Shipping_State_Province__c = acc.Shipping_State_Province__c; request.Shipping_Country__c = acc.Shipping_Country__c ; } } return request; }catch(Exception e){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,e.getMessage())); return null; } } set; }
For map covering map property :
Map<string,Basket__c> productGroupCodeToBasketItem = objMyClass.productGroupCodeToBasketItem();
All Answers
You would need to invoke the properties for covering them, process is same as for methods.
Example:
What about the Map property ?
For map covering map property :
Map<string,Basket__c> productGroupCodeToBasketItem = objMyClass.productGroupCodeToBasketItem();