Search
  • +44-7459919437 (UK- WhatsApp & Direct Call) | +91-6383544892 (India - WhatsApp Only) | Email Id : vinothrwins@gmail.com
Vinoth Tech Solutions
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I

TestNG Framework

  • What is TestNG Framework?
  • Advantages and Disadvantages of TestNG:
  • Difference between TestNG And Junit framework
  • What is TestNG Annotations?
  • Install TestNG In Eclipse & IntelliJ?
  •  Hierarchy In TestNG Annotations
  • TestNG’s prioritization
  • TestNG Dependent
  • Reporter Class in TestNG
  • TestNG Reports
  • Assertions in TestNG
  • TestNG Groups
  • TestNG Parameters
  •  Cross-Browser Testing in TestNG
  •  Parallel Testing in TestNG
  • Data Providers
  • TestNG Listeners
  • Rerunning failed tests in TestNG
View Categories
  • Home
  • Tutorials
  • TestNG
  • TestNG Framework
  • TestNG Groups

TestNG Groups

TestNG Groups 

What Are TestNG Groups?
TestNG groups allow you to categorize test methods into logical collections and then selectively run or skip them. You assign a method to one or more groups via the groups attribute on @Test:

@Test(groups = {“smoke”})

public void smokeTest() { … }

@Test(groups = {“regression”,”fast”})

public void fastRegressionTest() { … }

Group of Groups (Meta-Groups)
Sometimes you want to treat several groups as a single unit. TestNG lets you define a “meta-group” in testng.xml that aggregates other groups:

<groups>

  <!– Define a meta-group named “allTests” –>

  <define name=”allTests”>

    <include name=”smoke”/>

    <include name=”regression”/>

  </define>

  <run>

    <!– Run everything in “allTests” –>

    <include name=”allTests”/>

  </run>

</groups>

Here, allTests will encompass both smoke and regression methods 


Including and Excluding Groups
Within your <test> in testng.xml, you can specify exactly which groups to run or skip:

<suite name=”SuiteWithGroups”>

  <test name=”SelectiveTests”>

    <groups>

      <run>

        <!– Only run smoke tests –>

        <include name=”smoke”/>

        <!– Skip any slow tests –>

        <exclude name=”slow”/>

      </run>

    </groups>

    <classes>

      <class name=”com.example.tests.MyTests”/>

    </classes>

  </test>

</suite>

  • <include> — only these groups run
  • <exclude> — these groups are skipped

Regular Expressions and TestNG Groups
TestNG also supports regex patterns in your <include> or <exclude> names, enabling wildcard selections:

<groups>

  <run>

    <!– Include any group whose name starts with “reg” –>

    <include name=”reg.*”/>

    <!– Exclude any group ending in “_beta” –>

    <exclude name=”.*_beta”/>

  </run>

</groups>

This runs all groups like regression, regioTest, etc., while skipping v2_beta, feature_beta, and so on.

Putting It All Together
A full testng.xml combining these features might look like:

<!DOCTYPE suite SYSTEM “https://testng.org/testng-1.0.dtd”>

<suite name=”AdvancedGroupSuite”>

  <parameter name=”env” value=”staging”/>

  <test name=”GroupedRun”>

    <groups>

      <define name=”coreTests”>

        <include name=”smoke”/>

        <include name=”fast.*”/>

      </define>

      <run>

        <include name=”coreTests”/>

        <exclude name=”.*_deprecated”/>

      </run>

    </groups>

    <classes>

      <class name=”com.example.tests.MyTests”/>

    </classes>

  </test>

</suite>

With this you get:

  1. Meta-grouping (via <define>) to bundle related groups
  2. Selective execution (via <include>/<exclude>)
  3. Pattern matching (via regex) for flexible group names

Together, these capabilities give you powerful, maintainable control over exactly which tests run in each scenario.

testng framework
What are your Feelings

Share This Article :

  • Facebook
  • X
  • LinkedIn
Assertions in TestNGTestNG Parameters
© 2018 – 2025 Vinoth Tech Solutions Ltd (UK), Reg. No: 16489105