Monday, 9 March 2020

TestNG: @Test: run testcases in alphabetical order

If your test class has more than one test method (method that is annotated with @Test annotation), then the methods are executed in alphabetical order.

ExecutionOrderTest.java
package com.sample.app.arithmetic;

import org.testng.annotations.Test;

public class ExecutionOrderTest {

 @Test
 public void aTest() {
  System.out.println("a");
 }

 @Test
 public void dTest() {
  System.out.println("d");
 }

 @Test
 public void bTest() {
  System.out.println("b");
 }

 @Test
 public void cTest() {
  System.out.println("c");
 }

 @Test
 public void fTest() {
  System.out.println("f");
 }

 @Test
 public void eTest() {
  System.out.println("e");
 }

}

Run ‘ExecutionOrderTest’, you will see below messages in console.
a
b
c
d
e
f




Previous                                                    Next                                                    Home

No comments:

Post a Comment