How to Group Test Cases of Selenium

First Question, is Grouping of Test Cases in Selenium available?
Grouping of Test cases in Selenium is not available. Grouping feature is available in TestNG.

Before going to Grouping of Test Cases using TestNG in detail. Let us go through a scenario first.

Problem Statement :

We have a scenario where we have a very less amount of time and we need to execute only High level based scenarios. Where we should skip the low level or medium level based scenarios.

Solution : In this case, we can use TestNG feature where we need to group our test cases while creating the scripts itself. So that, it will be easy during this scenarios.

TestNG has provided an option to group the test cases and skip the certain group during the execution.

For Example : Like say if we have 10 test cases to execute out of which 4-Low Level, 3-High Level and 3 – Medium level test cases. We need to execute only the High Level Test Cases.

Below is the program for the Example :

Once Grouping of test cases is done. We need to specify in TestNG.xml file which groups to include or exclude. We give this include or exclude in TestNG.xml file.

– Will define in TestNG.xml file, as which test cases needs to be executed.

– Will define in TestNG.xml file, as which test cases needs to be skipped.

Program Grouping of Test Cases in Selenium :

From Group.xml file we can control which groups to be executed and which groups to Skip.

Like in the above Group.xml file

Skipping the Groups Low and Medium
Executing only Group named High
Will check the execution status by right clicking the Group.xml file and select RunAs–>TestNG Suite

TestNG-Grouping-High-Priority

Observe only Group named with High test cases are executed.

OUTPUT :

Leave a Comment

Your email address will not be published. Required fields are marked *