What happens when a test is executed - alandiaz08/e2e-web-framework GitHub Wiki

Flowchart TestExecution

1. Static member initializations

The primary step once the test execution begins, is the initialization of static members such as logger and WebDriverThreadPool. These static members are initialized at the start of the execution and only once.Based on the inheritance hierarchy, the members of DriverBase.java are first initialized followed by TestBase.java and BookingTests.java.

2. Annotation finder

The execution then moves to the current test class for example BookingTests.java to which an instance is created. Here the members are initialized and testNG identifies all the methods with annotations. SuiteTestRunner.java and TestRunner.java which initializes the testNG reports, configurations and identifies the number of tests in the suite.

3. Execution of annotations

The methods in the annotations @BeforeSuite ,@BeforeMethod, @Test, @AfterMethod and @AfterSuite are executed in sequence.

@BeforeSuite

Inside the startSuite() method of @BeforeSuite,

  1. A webDriverThreadPool with multiple drivers which can be shared across multiple executions in case of parallel run is created.
  2. Each log will be written on a file depending on the threadName. This is to write the logs in different files when multiple test cases are executed in parallel.
  3. Configurations such as Environment and Domain will be set up by initializeEnvironment() method. If no configuration has been provided at runtime, default values ( Environment=PREPROD , Domaine =fr_FR) will be set.

@BeforeMethod

Inside the startTest() method of @BeforeMethod ,

  1. The extent report step counter is set to 1. The generation of logs and extent reports will begin at this step.

@Test

Inside the @Test annotation the actual test execution for example bookingDhpSearchPageTimeslot() starts. It has been designed in the following order.

-Arrange

  1. The required variables are declared and values are assigned.

-Act

  1. Gets the WebDriver stored in the ThreadLocal variable.
  2. The page which has to be opened at the start is initialized which opens the URL. In our tests, the starting point of most of the WNG tests will be homePage, RestaurantPage and SearchPage.

-Assert

  1. Conditions specific to each tests are asserted here.

@AfterMethod

Inside the finishTest() method of @AfterMethod,

  1. The test results are sent to elasticSearch for storing the data for future analysis.
  2. The test status is updated in the extentReports and logs. If there is a failure or a skipped test, the screenshot is added to the report.
  3. If the tests are run by Zalenium, it adds a video recording to the report.

@AfterSuite

Inside the finishSuite() method of @AfterSuite,

  1. The driver is quit.