What’s the actual use of ‘fail’ in JUnit test case?
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.
Some cases where I have found it useful:
Note:
Since JUnit4, there is a more elegant way to test that an exception is being thrown:
Use the annotation
@Test(expected=IndexOutOfBoundsException.class)However, this won’t work if you also want to inspect the exception, then you still need
fail().