How to Run Karate API tests on Azure pipelines

Viewed 1992

New to Karate & Azure. Just created few API tests using Karate and easy simple. Want to take it further adding it Azure pipeline.

Found few links that just points to add pom.xml and maven from Microsoft. Also found Jekins integration but none for Azure.

Unknown / How to.

  1. What file needs to be moved to the pipeline, eg, jar, war, xml etc.

  2. How to create them i use intelliJ.

  3. Any step by step tutorials available? any help appreciated.

1 Answers

To run Karate tests on azure devops pipeline, you can follow below general steps for building/testing java project.

1, First create your Karate tests projact with Maven. Add the related dependencies and plugins in the pom.xml. See example here.

2, Push your local source code(eg. .feature/.java/pom.xml etc) to github, or azure devop git repository. No need to push .jar dependencies, for the dependencies can be downloaded by the Maven task in the pipeline.

3, Create a azure pipeline, Follow this example to create a Yaml format pipeline. If you want to create a classic UI view pipeline, follow the example here.

4, Add Maven task in your pipeline to run the Karate test: See below example in Yaml.

steps:
- task: Maven@3
  displayName: 'Maven Test'
  inputs:
    mavenPomFile: 'pom.xml'
    goals: test
    publishJUnitResults: false

If You use Microsoft cloud hosted agents to run your pipeline, you need to make sure the API tested by Karate can be accessed from the cloud hosted agents.(ie. API can be accessed publicly)

If the API server is hosted locally, you need to create self-hosted agent, and run your azure pipeline on your self-hosted agent.

Related