I have some common set up code that I\'ve factored out to a method marked with @Before. However, it is not necessary for all this code to run for every single t
It is possible to achieve also via Assume from JUnit. And then you can check the method name for which you want to process @Before.
public class MyTest {
@Rule
public TestName testName = new TestName();
@Before
public void setUp() {
assumeTrue(testName.getMethodName().equals("myMethodName"));
// setup follows
}
}
Check the topic for more insights about @Rule.