Is it too bad to write a really long (more than 200 lines) test method? Or should I break it up into smaller-methods?
Share
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.
You shouldn’t (on the whole) create any method that’s 200 lines long. If you can break it up, do.
What are you doing in 200 lines? Unit testing should be testing small units of code. Are those 200 lines predominantly assertions? If so, then that might be OK.
The key question is – can someone understand what the method’s doing quickly, or is it hard to get your head around?