Managing Smoke and Regression test with maven profiles



Hi all in this blog post I will discuss how we can make use of maven profile to manage our smoke test and regression tests. The approach discussed below is useful when we look at our test in terms of a framework.

Smoke test are those that cover the happy path of test cases to determine if the build is ready for more detailed test cycle. Where as regression test is used to determine if existing features are not affected with any resent bug fixes. Discussed below is how we can use TestNG and Maven in combination to achieve the objective.

Lets say we want to identify a selected set of test for Smoke test, the way that we can achieve this is to make use of the @Test[group={"smoke"}] and then create a new TestNG file to list those group of test identified for Smoke test.

Now lets say we have multiple TestNG files for Regression and Smoke test when invoking those test with the use of Maven we need to identify an efficient way to ensure that we can invoke the required group of test with the use of a command line option. To achieve this we can make use of the profiles tag within the pom file. Shown below is how we can make use of profiles with our pom.xml file

<profile>
 <id>Smoke</id>
 <build>
  <pluginManagement>
   <plugins>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <version>2.20.1</version>
     <configuration>
      <suiteXmlFiles>
       <suiteXmlFile>testng-smoke.xml</suiteXmlFile>
      </suiteXmlFiles>
     </configuration>
    </plugin>
   </plugins>
  </pluginManagement>
 </build>
</profile>
</profiles>


As shown above, the pom file can be added with multiple profiles for the Regression and Smoke test and we can call the relevant TestNG file. Once the POM files is updated to run our test we can issue a command that calls the relevant profile with a command as mvn test -PSmoke. With this way with the minimum changes to our POM file at run time we can invoke the relevant tests that we need to invoke,









Comments