Run test methods in sequential order

0

Hello,

I have one Junit test class with two test methods in it.

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Class1 {
@Test
public void method1() {....}
   @Test
public void method2() {....}
   @BeforeClass
    public static void setUp() {
        driver = new AndroidDriver(new URL(URL), getCapsAndroidEmulAut());
   }
   @AfterClass //executed after run all methods
   public static void tearDown() {
        driver.quit();
}
}

When I run this test, I want run method1 first, and keep state of app in device to execute method2 (this is standard behaviour of Junit). But AWS Farm run method1 and then reinitialize the state of device and run method2 with a new state.

Is there any configuration to have the standard behaviour ?

Environnemnt : Junit/Appium

Thank you

asked a year ago232 views
1 Answer
0

I understand the problem. for a test class like :

 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class Class1 {
@Test
public void method1() {....}
   @Test
public void method2() {....}

   @BeforeClass
    public static void setUp() {
        driver = new AndroidDriver(new URL(URL), getCapsAndroidEmulAut2());
   }
   @AfterClass
   public static void tearDown() {
        driver.quit();
 }
}

AWS Device Farm considers Class1 as a suite, each method as a class. According to the results: Farm executes setUp(), then method1(), then tearDown() (this is the first suite) Then Farm executes a new suite : setUp(), then method2(), then tearDown().

While the standard behavior of JUnit is Class1 is a class, il execute setUp(), method1(), method2(), and tearDown().

Any help ?

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions