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

posta un anno fa246 visualizzazioni
1 Risposta
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 ?

con risposta un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande