TestNG Maven Surefire Plugin Configurations

Filed Under: TestNG

TestNG Maven surefire plugin configurations let us define which tests to execute when we run the maven build. When we have a large project with many test cases, then it comes handy to configure only specific test suites for execution.

TestNG Maven Project

During the series of TestNG Tutorials here, I have created a lot of test classes and TestNG XML suite files. Below image shows the current project structure and all the test classes it has.

TestNG Maven Project

Now when I run a maven build, it scans the project and executes all the test classes. So project build takes a lot of time. If I am interested in specific tests only, chances are that its logging gets lost in all the noise created by other tests.

TestNG maven build running all tests

Maven Surefire Plugin

Maven surefire plugin is used to run the project tests. It also allows us to configure which XML suites to execute when we build our project. Below configuration will tell maven surefire plugin to execute only testng.xml and test_parameters.xml test suite files.

                   <!-- TestNG Suite XML files list for test execution -->

Now when we perform maven build by running mvn clean install or mvn test commands, we get a clean output for our tests.

TestNG Maven Surefire plugin XML Suite files

That’s all for configuring maven-surefire-plugin to execute only specific TestNG XML suite files.

You can download the example code from our GitHub Repository.


  1. Swapnil says:

    Hello, I am getting “could not find or load main class ” error

  2. chandrika.Chilakalapudi says:

    I am getting following error,pleases help me with thses
    1.WebDriver Timed out waiting for driver server to start

  3. raja says:

    Hi , i am trying to download the project from GitHub, there is no option to download this particular project, so i had downloaded the root folder , which have so many projects, for some unknown reason, i am not able to find the TestNG-Examples project in it. please help me.

Comments are closed.

Generic selectors
Exact matches only
Search in title
Search in content