You can control the test case execution by org.junit.Assume.assumeTrue(condition), Which ignores the test cases if it found the condition to be false. Sets the condition to be true in the beginning, a private static boolean variable can be user for example and the sets the condition to false in the end of the last test case that you want to be executed. Checks the condition in @BeforeTest.
Sample code
private static boolean runTest = true;
@org.junit.Before
public void before() throws Exception {
org.junit.Assume.assumeTrue(runTest);
}
@org.junit.Test
public void test1() throws Exception {
// will be executed
}
@org.junit.Test
public void test2() throws Exception {
// will be executed
}
@org.junit.Test
public void test3() throws Exception {
// will be executed
runTest = false;
// no test after this will be executed
}
@org.junit.Test
public void test4() throws Exception {
// will be ignored
}