After a test fails, to run it again, I need to restart Appium server from Appium GUI tool

After a test fails, I need to go to the Appium server UI to stop and launch the server manually, to run the same test again.
Is there a better way? Am I missing something in testNG ?

public class CreateIssueTest extends TestUnitBaseAndroid {

public void setUp() throws Exception {
	driver = new SwipeableWebDriver(new URL(WEBDRIVER_URL), capabilities);
	loginPage = PageFactory.initElements(driver, LoginPage.class);
	feedPage = loginPage.testLogin(EMAIL, PASSWORD, SERVER);

public void tearDown() {

public void beforeTest() {

public void afterTest() throws IOException {
	// doAfterTest();

public void afterMethod() throws IOException {

public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
	private RemoteTouchScreen touch;

	public SwipeableWebDriver(URL remoteAddress,
			Capabilities desiredCapabilities) {
		super(remoteAddress, desiredCapabilities);
		touch = new RemoteTouchScreen(getExecuteMethod());

	public TouchScreen getTouch() {
		return touch;

public class TestUnitBaseAndroid extends TestUtils{

public TestUnitBaseAndroid() {
	log = LoggerUtils.getLogger();"log4j initialized");

public static volatile WebDriver driver;
//public static AndroidDriver driver;
public static DesiredCapabilities capabilities;
public static final String WEBDRIVER_URL = "";
public static String baseUrl;
public static Logger log;

public static LoginPage loginPage;
public static NavMenuPage navMenuPage;
public static FeedPage feedPage;
public static IssuesPage issuesPage;
public static FollowingPage followingPage;
public static SupplierPage supplierPage;
public static AboutPage aboutPage;
public static SettingsPage settingsPage;
public static LogoutPage logoutPage;
public static CreateIssuePage createIssuePage;

public static final String APP_PATH = "/Users/username/UserFiles/dev/apks/";

public static final String RESOURCES_PATH = "src/test/java/com/mycompany/qe/clients/resources/";
public static final String loginPagePropertiesFile = RESOURCES_PATH + "";
public static String USERNAME = null;
public static String PASSWORD = null;
public static String SERVER = null;
public static String EMAIL = null;

public static void doSetup() {
	Properties properties = PropertyUtils.getProperties(loginPagePropertiesFile);
	USERNAME = properties.getProperty("username");
	PASSWORD = properties.getProperty("password");
	SERVER = properties.getProperty("server_android");
	EMAIL = properties.getProperty("email");

	capabilities = new DesiredCapabilities();
	// File appDir = new File(System.getProperty("user.dir"), "");
	File app = new File(APP_PATH, "appExposure-adhoc.apk");
	capabilities.setCapability("deviceName", "Nexus_5_API_21");
	capabilities.setCapability("platformVersion", "5.1");
	capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("app", app.getAbsolutePath());		


public static void doTeardown() {
	driver.quit(); // poof

public static void doAfterTest() {
	String msg = "All tests completed";

public static void doAfterMethod() {
	String msg = "Test completed";

What error do you get, make sure you see the DELETE session call in the server log?

Ideally your driver.quit() call in teardown should close the driver.

I think you are hitting a case where teardown not called.

Can you try adding alwaysRun=true to your AfterMethod annotation.

Thank you, sebv & RamS. It is working now. :sunny:

@Mayu_Kataoka, Can you please let me know how you solved the problem. I am still facing the issue.