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
sumit singh 37sumit singh 37 

How to Cover This lines in Test Class

 public List<String> kamNa {
        get {
            if (kamNames == null) {                
                kamNames = new List<String>();
                Schema.DescribeFieldResult field1 = Brokerage__c.Control__c.getDescribe();                
                for (Schema.PicklistEntry f : field.getPicklistValues())
                    kamNa.add(f.getLabel());               
            }
            return kamNa;          
        }
        set;
    } 
Best Answer chosen by sumit singh 37
Abhishek BansalAbhishek Bansal
Hi Sumit,

There was a mistake in code provided by me which i have ocrrected now.
So please try with this updated code :
YourClassName testController = new YourClassName ();
List<String> testPropertyCall = testController.kamNa;

//Replace YourClassName with name of your class.

Let me know if you still have any issue.

Thanks,
Abhishek

All Answers

Abhishek BansalAbhishek Bansal
Hi Sumit,

Please try with below code :
YourClassName testController = new YourClassName ();
List<String> testController = controller.kamNa;

//Replace YourClassName with name of your class.
Please let me know if there is any issue with above code.

Thanks,
Abhishek
sumit singh 37sumit singh 37
Hi Abhishek

No it wont work 
becz the this is not a static variable
and the testController and controller reference the same class
i tried it gave me an error of controller.kamNa variable not defined
thanku for your reply
Abhishek BansalAbhishek Bansal
Hi Sumit,

There was a mistake in code provided by me which i have ocrrected now.
So please try with this updated code :
YourClassName testController = new YourClassName ();
List<String> testPropertyCall = testController.kamNa;

//Replace YourClassName with name of your class.

Let me know if you still have any issue.

Thanks,
Abhishek
This was selected as the best answer
Allen li 3Allen li 3
I think Abhishek is right. As a property, testController.kamNa should be right and this statement shouldn't cause error. 

FYI, you can try a new salesforce development IDE named Metaforce on chrome application platform. it's a great tool for coding, deploying, etc.. you can try to search and install it in chrome webstore or click this link.(https://chrome.google.com/webstore/detail/metaforce/hhnkaakhlhngcdckdiogpkjihnmgodep)
User-added image