All tests in my test class execute a ‘before’ method (annotated with JUnit’s @Before) before the execution of each test.
I need a particular test not to execute this before method.
Is there a way to do it?
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.
Unfortunately you have to code this logic. JUnit does not have such feature.
Generally you have 2 solutions:
@RequiresBeforeand mark tests that need this with this annotation. The test runner will parse the annotation and decide whether to run “before” method or not.The second solution is clearer. The first is simpler. This is up to you to chose one of them.