🔧Maven- Project & Build Management Tool — Article #3

🔌Surefire Plugin In Maven

Importance & Use of Surefire Plugin

Fareena Imran
CodixLab

--

In this article, we are going to learn about the Surefire plugin in maven. Let’s get started 👇

Surefire Plugin

According to Apache:

The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application.

Importance of Surefire Plugin

◾️The Surefire Plugin is used to execute all the test cases in the Maven project.

◾️Basically, it's used to follow the sequence of test cases in the testng.xml file. If you don’t put the Surefire plugin code in pom.xml then it will execute all the tests that are placed under the ‘src/test/java’ and these tests will get executed without any sequence.

◾️Surefire Plugin gives additional control or flexibility of what test cases are needed to include, what to execute, what to skip, parallelism, excluding groups, defining group and thread-count, etc.

◾️It provides the results of test execution in report format. The two different file formats are :

✔️Plain text files (*.txt)

✔️XML files (*.xml)

How To Use ❔

Usually, you don´t need to define it inside pom.xml it will be executed and downloaded when the maven project needs it. But in case you don't get it then to use the Surefire plugin you need to put the plugin code in the pom.xml file.

If you’re using the latest version of maven then this plugin will be already in pom.xml otherwise you need to follow these steps 👇

#1) Copy the plugin code from the official website. Copy the code from <build> to </build> tag.

#2) Open the pox.xml file in the Maven project and paste this code above the <dependencies> parent tag.

In this way, you can use the Surefire plugin in the maven project to execute your test cases.

Follow 👉 all the articles to learn more about Maven. In the next article, we will learn about the important commands of MAVEN.

Best of Luck 👍

--

--

Fareena Imran
CodixLab

SQA Engineer| Tech Writer | Write stories about SQA