I just wonder if I want to make my code more testable, should I use private variables?
If not, when should I use private variables?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Private variables should just be used for internal storage for your class not testing directly against. Set up your class how it is designed to be accessed with the proper properties and methods, then write your test to access your properties and methods just as any other part of your code would.