5

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.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
Devanathan
  • 63
  • 1
  • 4

2 Answers2

6

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.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • Thank you For your Prompt Reply. Shall try this solution and update results. – Devanathan Aug 20 '20 at 08:37
  • 1
    @peterthomas,That worked and i am now able to put my tests on azure thankyou, i.e, got my .feature,java, and pom.xml in the pipeline. 1. pom.xml file mapped to th maven and all running well and pipeline shows green after running. 2. But i get a snapshot.jar file and i don't see any reports. 3. I feel i am not calling the .java file, which inturn calls the .feature file for the tests to execute. 4. I can't see any reports. how do i get them to be added. 4. Any help on this appreciated, so that i can see my tests run and reports generated. – Devanathan Aug 24 '20 at 11:07
1

@Devanathan Better way is go for Publishing artifacts for both a) your Cucumber Report
b) Your Karate HTML report. Anyone can download both the artifacts (i.e reports from pipeline) and see the Report.
I tried to publish cucumber-html-reports (this is the exact name of folder that Karate generates) and was successful.
I intentionally kept report output directory in src/test/java for some reason [by using .reportDir("src/test/java/reports") in testParallel() method], you can try same by keeping reports in 'target' folder only. enter image description here

I was not able to Publish Karate HTML report as somehow its not being picked in azure

Manish Arya
  • 113
  • 1
  • 7