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

已提問 1 年前檢視次數 246 次
1 個回答
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 ?

已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南