5

Jenkins Integration using Karate DSL

 2 years ago
source link: https://blog.knoldus.com/jenkins-integration-using-karate-dsl/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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
  • 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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK