How to exclude TestNG Groups from Maven? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report To exclude specific TestNG groups from execution when running tests through Maven, you can configure the maven-surefire-plugin in the Maven pom.xml file. The Surefire plugin is responsible for running the unit tests during the build process, and it supports excluding certain groups from being executed.Approach to Exclude TestNG Groups from MavenFollowing are the steps to exclude TestNG groups from Maven:Create a Maven Project: First, create a maven project on any ide like Eclipse or IntelliJ Create a class: Create a java class (eg:TestClass1) under src/test/java in that Maven projectAdd Test Methods: Add Test Methods in each class using @test annotation add a group attribute to each method and write your logic in that test method.Configure POM.xml file: In the pom.xml file, configure the maven-surefire-plugin to exclude specific groups using the <excludedGroups> tag. This tag allows you to specify which groups should be excluded during test execution.Run the project: To run the project. Open the terminal and write the mvn test, this will exclude the group.Example CodeTestClass1.java Java package TestNG.SeleniumJava; import org.testng.annotations.Test; public class TestClass1 { @Test(groups = "group1") public void testMethod1() { System.out.println("TestClass1 - testMethod1 from group1"); } @Test(groups = "group2") public void testMethod2() { System.out.println("TestClass1 - testMethod2 from group2"); } } pom.xml XML <project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>TestNG</groupId> <artifactId>SeleniumJava</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>SeleniumJava</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> <configuration> <excludedGroups>group2</excludedGroups> </configuration> </plugin> </plugins> </build> <dependencies> <!-- https://mvnrepository.com/artifact/org.testng/testng --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.7.1</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> Output:In order to run the project. Open the terminal and write the following command, this will exclude the group.mvn testConclusionBy configuring the maven-surefire-plugin in the pom.xml file and using the <excludedGroups> tag, you can easily exclude specific TestNG groups from being executed during the Maven build process. This allows for greater flexibility in controlling which tests are run, especially in scenarios where certain tests are not relevant or are under development. Comment More infoAdvertise with us Next Article What is Software Testing? C cyrust8t7y Follow Improve Article Tags : Software Testing Testing Tools Maven TestNG Similar Reads Software Testing Tutorial Software testing is an important part of the software development lifecycle that involves verifying and validating whether a software application works as expected. It ensures reliable, correct, secure, and high-performing software across web, mobile applications, cloud, and CI/CD pipelines in DevOp 10 min read What is Software Testing? Software testing is an important process in the Software Development Lifecycle(SDLC). It involves verifying and validating that a Software Application is free of bugs, meets the technical requirements set by its Design and Development, and satisfies user requirements efficiently and effectively.Here 11 min read Principles of Software testing - Software Testing Software testing is an important aspect of software development, ensuring that applications function correctly and meet user expectations. From test planning to execution, analysis and understanding these principles help testers in creating a more structured and focused approach to software testing, 3 min read Software Development Life Cycle (SDLC) Software Development Life Cycle (SDLC) is a structured process that is used to design, develop, and test high-quality software. SDLC, or software development life cycle, is a methodology that defines the entire procedure of software development step-by-step. The goal of the SDLC life cycle model is 8 min read Software Testing Life Cycle (STLC) The Software Testing Life Cycle (STLC) is a process that verifies whether the Software Quality meets the expectations or not. STLC is an important process that provides a simple approach to testing through the step-by-step process, which we are discussing here. Software Testing Life Cycle (STLC) is 7 min read Types of Software Testing Software testing is a important aspect of software development life-cycle that ensures a product works correctly, meets user expectations, and is free of bugs. There are different types of software testing, each designed to validate specific aspects of an application, such as functionality, performa 15+ min read Levels of Software Testing Software Testing is an important part of the Software Development Life Cycle which is help to verify the product is working as expected or not. In SDLC, we used different levels of testing to find bugs and errors. Here we are learning those Levels of Testing in detail.Table of ContentWhat Are the Le 4 min read Test Maturity Model - Software Testing The Test Maturity Model (TMM) in software testing is a framework for assessing the software testing process to improve it. It is based on the Capability Maturity Model(CMM). It was first produced by the Illinois Institute of Technology to assess the maturity of the test processes and to provide targ 8 min read SDLC MODELSWaterfall Model - Software EngineeringThe Waterfall Model is a Traditional Software Development Methodology. It was first introduced by Winston W. Royce in 1970. It is a linear and sequential approach to software development that consists of several phases. This classical waterfall model is simple and idealistic. It is important because 13 min read What is Spiral Model in Software Engineering?The Spiral Model is one of the most important SDLC model. The Spiral Model is a combination of the waterfall model and the iterative model. It provides support for Risk Handling. The Spiral Model was first proposed by Barry Boehm. This article focuses on discussing the Spiral Model in detail.Table o 9 min read What is a Hybrid Work Model?Hybrid means a thing made by a combination of two different elements and the resulting hybrid element acquires characteristics of both underline elements. The following topics of the hybrid model will be discussed here:What is the Hybrid Model?Why the Hybrid Model?When To Use a Hybrid ModelProcess o 13 min read Prototyping Model - Software EngineeringPrototyping Model is a way of developing software where an early version, or prototype, of the product is created and shared with users for feedback. The Prototyping Model concept is described below: Table of ContentWhat is Prototyping Model?Phases of Prototyping ModelTypes of Prototyping ModelsAdva 7 min read SDLC V-Model - Software EngineeringThe SDLC V-Model is a Types of Software Development Life Cycle (SDLC), which is used in Software Development process. In V-Model is the extension of the Traditional Software Development Model.It is creating a Structure like the "V" which includes the different phases which we are discussing here in 10 min read TYPES OF TESTINGManual Testing - Software TestingManual testing is an important part of software development. Unlike automated testing, it involves a person actively using the software to find bugs and issues. This hands-on approach helps ensure the software works as intended and meets user needs. Table of ContentWhat is Manual Testing Types of Ma 14 min read Automation Testing - Software TestingAutomated Testing means using special software for tasks that people usually do when checking and testing a software product. Nowadays, many software projects use automation testing from start to end, especially in agile and DevOps methods. This means the engineering team runs tests automatically wi 15+ min read Like