Maven Tutorial
Introduction to Maven Installation and environment configuration Maven settings Standard directory structure in Maven project command line IntelliJ IDEA Super POM and Parent POM Understanding POM.xml file Declaring maven dependencies Dependency management using repositories in Maven Adding jar file as a dependency in Maven Maven archetypes Maven build life cycle, phases and goals Generating project API documentation Generating Site documentation for a project Installing artifacts in local repository Deploying the artifact on remote repository Maven plug-ins surefire plugin compiler plugin Profiles in MavenExecuting Maven phases and goals through command prompt Maven command line optionsexec-maven-plugin usage Skipping tests in Maven Test execution report in MavenSurefire plugin in Maven
The Surefire Plugin executes the tests (JUnit/testNG) in maven project. Surefire stores the test execution report at /target/surefire-reports. Configuration of surefire plugin- suiteXmlFile – specify the xml file containing tests to be executed
- groups – specify the group names to be included. Tests belonging to those groups will be executed.
- excludedgroups – specify the group names to be excluded. Tests belonging to those groups will not be executed.
- parallel – If you want to execute tests in parallel, use this tag. Possible values for this tag can be methods, classes
- threadCount – How many threads should be created at a time to execute tests?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<groups>sanity, regression</groups>
<excludedgroups>smoke</excludedgroups>
<parallel>methods</parallel>
<threadCount>3</threadCount>
</configuration>
</plugin>
Executing the tests through command line
By default, the Surefire Plugin will execute tests from all the classes with their names containing string – Test If you want to execute all tests from the maven project, use below command.
mvn surefire:test
If you want to run tests from single class, you can use below command.
mvn -Dtest=TestCircle test
If you want to run failed tests again, you can execute below command. Meaning of 3 in below command is that test will be executed at the most 3 times.
mvn -Dsurefire.rerunFailingTestsCount=3 test
Web development and Automation testing
solutions delivered!!