Jenkins Integration using Karate DSL

Reading Time: 2 minutes

In the previous blog we saw how we can use karate DSL and read data from external files. Now, in this blog we will see how we can have Jenkins integration using karate DSL.

Requirements

  • Jenkins
  • JDK
  • karate project

Setting up Jenkins

We will be using a maven project and a java class to execute our test. In order to do that we will be required to configure JDK in Jenkins.

  • Log in into Jenkins and go to Manage Jenkins.
  • Go to Global Tool Configuration.
  • Go to JDK and click on Add JDK.
  • Here you have 2 options either install it automatically by selecting a checkbox (Install automatically), selecting the version and entering your oracle account details. You are required to have a valid oracle account.
  • Or you can unselect the checkbox and provide the name and path to your local JDK.
  • Save the configurations and create a new freestyle project.
  • In the Git section provide the link to you repository for cloning it automatically. If the repository is private then add you Git credentials else leave it as none.
  • Go to build section and Add build step for Execute shell.
  • In the command section enter the following command.
mvn test -Dtest=TestUsersRunner
  • TestUsersRunner is the name of class that has the name of the .feature file which we will be executing.
package examples.users;

import com.intuit.karate.junit5.Karate;

class TestUsersRunner {
    
    @Karate.Test
    Karate testUsers() {
        return Karate.run("POSTandGETCall.feature").relativeTo(getClass());
    }    

}
  • POSTandGETCall.feature is the file which we will be executing.
  • Save the Jenkins project and click on Build now.
  • Our feature file has been successfully executed.

So, this is a short blog on how we can have Jenkins Integration using Karate DSL. See you in the next one.

References:
https://github.com/intuit/karate
https://www.youtube.com/watch?v=Y-v-iUDy4NM


Knoldus-blog-footer-image

Written by 

Ankur is a QA Consultant having experience of more than 1.5 years. He is familiar with the core concepts of manual and automation, postman and Newman are his expertise. He is always eager to learn new and advance concepts in order to expand his horizon and apply them in project development with his existing knowledge. His hobbies include watching web series and getting to know about all the latest gadgets that come in the market.