I need to cover some tests with JUnit. My method returns java.io.File. What are the attributes I need to check?
- check file size?
- check file name?
- check …?
How do you write JUnit tests for methods, that operate with files? Is there any frameworks?
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.
There is no “best way”. It completely depends on what the file is supposed to contain, and what you NEED TO test.
In different situations I might test that:
Fileargument is non-null,Filehas a given value,