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.