How to select the order of which Test case to run in Eclipse android

How to select the order of which Test case to run in Eclipse android

here is my code :

ackage appium.learning;


import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class LearningTest {

WebDriver driver;

public void setUp() throws MalformedURLException{
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("device", "Android");
    capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
    capabilities.setCapability(CapabilityType.VERSION, "4.4");
    capabilities.setCapability(CapabilityType.PLATFORM, "Android");
    capabilities.setCapability("app-package", "com.myapp"); //Replace with your app's package
    capabilities.setCapability("app-activity", ".myapp"); //Replace with app's Activity
    driver = new RemoteWebDriver(new URL(""), capabilities);

public void tearDown(){

public void Cal1(){
public void Cal2(){
public void Cal3(){
public void Cal4(){


I want them to run in order, lke, 1, 2, 3, 4


Appium can’t help you much here. My best suggestion would be to do a google search for ‘ordering tests in junit’. Note that this is completely against the philosophy of junit (read their FAQ for more details, but loosely paraphrased, ‘test should be able to be run in an arbitrary order & not dependent on each other’) but there is this:

import org.junit.FixMethodOrder;


HTH. I encourage you to do a google search & read up about this.

@Wreed is correct, tests should be independent of each other.
You can achieve ordering with TestNG tool, Please refer and .

Also can you explain why you need to run test cases in a specific order ?

I think wreed is correct but in a certain case we can have tests depend on the others.

For example, I have a flow including two steps in order: step1 and step2. And I have 2 test cases: one for step1 and one for the whole flow. So I would like to run the second test only if the first test is passed and in testNG they have attribute “dependsOnMethods” come a long with @Test annotation which allows you to define the running order.

I am not sure if junit has something like that though, you can look it up in their documents.