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

demandé il y a un an246 vues
1 réponse
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 ?

répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions