I would like to write junit tests for my java classes
The objective is to read contents from a text file and doing some basic operations and calculations.
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.
Read the documentation on JUnit – Brian Roach has given you a link in the comments.
Decide what your classes are supposed to do. Think about how they could go wrong, and how they should deal with bad input.
For each thing that they should do, and each thing they should not do, write a test method that proves that they behave correctly.
If your test becomes long and complicated, that is often a sign that your original code is not structured well enough. Fix it.
Practise.