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.
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.
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.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<!-- TestNG Suite XML files list for test execution -->
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
<suiteXmlFile>src/test/resources/test_parameters.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
Now when we perform maven build by running mvn clean install
or mvn test
commands, we get a clean output for our tests.
That’s all for configuring maven-surefire-plugin to execute only specific TestNG XML suite files.
Hello, I am getting “could not find or load main class ” error
I am getting following error,pleases help me with thses
1.WebDriver Timed out waiting for driver server to start
2.org.openqa.selenium.net.UrlChecker$TimeoutException
3.java.util.concurrent.TimeoutException
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.
Refer this to download only specific folders:
https://stackoverflow.com/questions/7106012/download-a-single-folder-or-directory-from-a-github-repo