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?
Unfortunately you have to code this logic. JUnit does not have such feature. Generally you have 2 solutions:
@RequiresBefore
and 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.