Skip to content

artofcode.info

The beauty of coding!

Menu
  • Home
  • Front-End
    • Angular
    • Javascript
    • ReactJS
  • Back-End
    • Java
    • Php
  • Test Automation
  • News
Menu

How to create jenkins generic runner based on cucumber tags

Posted on August 19, 2019August 19, 2019 by guru

Today we are going to jump a little bit in CI/CD with a generic jenkins runner based on cucumber tags. In this post will be detailed explained how to configure the runner and how to create the generic profile on real project, let’s start…

Creating maven profile based on failsafe plugin to run CucumberRunner.

The profile will contains the maven-failsafe-plugin to run java test, and how you know the cucumber runners is a simple java test.

In cucumber options we have [CDATA[${tags}]] here we will send tag name with -D options, Let’s consider an example : -Dcucumber.options=”–tags @UI “.

<profile>
  <id>generic-runner</id>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
          <forkCount>1</forkCount>
          <reuseForks>true</reuseForks>
          <includes>
            <include>**/RunAllTests.java</include>
          </includes>
          <argLine>-Xmx1024m -Dfile.encoding=${project.build.sourceEncoding}</argLine>
          <systemPropertyVariables>
            <cucumber.options><![CDATA[${tags}]]></cucumber.options>
          </systemPropertyVariables>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile> After adding the profile the <tags>--tags ~@ignore</tags> parameter should be add in pom.xml property.

Configure jenkins job:

An important part of jenkins job is to start our profile with maven command:

jenkins-conf

In order to run test based on another tag, just change the  @UI tag from following mvn command: clean install -Pgeneric-runner -Dcucumber.options=”–tags @UI “.

Or you can add multiple tags on your jenkins execution. Hope this will help you to improve your testing CI/CD.

Recent Posts

  • Cucumber JUnit XML report with logs
  • How to add log messages to the cucumber Jenkins report
  • Factory Method Pattern in the creation of Selenium WebDriver
  • How to attach log message to cucumber report via MDC
  • How to send different values in cucumber features based on profile
  • How to log execution time for cucumber steps
  • Strategy Pattern in Test Automation with Selenium WebDriver
  • Spring Security with JWT token

Categories

  • Back-End
  • Java
  • News
  • Test Automation
© 2023 artofcode.info | Powered by Minimalist Blog WordPress Theme