+ Start a Discussion
GasPanic86GasPanic86 

How to bulk controller extension test class

hi, I have to write a test class for controller extension. How we apply best practice about bulking in this case? Controller extension constructor takes one standard controller instance. Do i have to instantiate for 200 Times the controller extension in test class? Thank you in advance 
Best Answer chosen by GasPanic86
Ravi Dutt SharmaRavi Dutt Sharma
Bulk testing is mostly applicable for triggers where you expect 1 to 200 records in one shot. For controller extension, I dont see any point to perform a bulk testing as it would be tied to always single record. Let me know if your case is otherwise.

All Answers

Ravi Dutt SharmaRavi Dutt Sharma
Bulk testing is mostly applicable for triggers where you expect 1 to 200 records in one shot. For controller extension, I dont see any point to perform a bulk testing as it would be tied to always single record. Let me know if your case is otherwise.
This was selected as the best answer
GasPanic86GasPanic86
Thank you so much, Ravi. I would like to ask you about another point. About this controller extension i have to test different use cases based on different values of the record’s fields. Is it a best practice to instantiate more controller extension constructors passing them different version of the records ? Or the best practice is to update the single record and then to pass it to the same (or a new) instance of the controller extension? I hope I’ve been understandable...thank you 
Ravi Dutt SharmaRavi Dutt Sharma
You should always try to mimic the user flow in your test class. If the user is interacting with your page and the record changes in that period of time, then you should also update the record in your test class. On the other hand, if the record remains unchanged in the entire user transaction, then you should instansiate multiple constructors in your test class.