You need to sign in to do that
Don't have an account?
How to test List <Select Option>
I'm trying to improve the code coverage in a class that actually is 76%. In the class I have the following code that is not tested :
Public List <SelectOption> buildingListOption {get{//2&3
List<selectOption> buildingList =new List<selectOption>();
for(integer indx_j=0;indx_j<BuildList.size();indx_j++)
buildingList.add(new selectOption(BuildList[indx_j].id,BuildList[indx_j].name));
return buildingList;
}//3
private set;
}//2
Taking out this code the coverage raised 5%. This code appears twice in the class then its weight is 10% in my code.
My question is how can I test this code.
Gustavo
I'm assuming that this is in a controller of some description as its returning selectoptions.
To test this, you simply need to access the property. Something like:
All Answers
I'm assuming that this is in a controller of some description as its returning selectoptions.
To test this, you simply need to access the property. Something like:
I want to ask a question - Does assert statement increase code coverage?
To my understanding assert only checks two values and is for our satisfaction only.
Bob can you please enlighten me towards this.
Thank you!
You are correct - the assert statement doesn't increase code coverage, as it doesn't execute any of the code that you are testing.
Assert statements allow you to verify that the code has performed as per its "contract" - thus if the behaviour of the code was changed unintentionally, the next time the unit test is run the assert will cause a failure.
If the behaviour of the code is changed intentionally, then the unit tests (and all affected code) would be changed to reflect the new behaviour as part of the development process.
Thanks Bob.
Thanks Bob
please go throw below link and send me how to get my test code coverage more than 75%, i wrote test class it gives 70% only.
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000ApnPIAS