如何在 Azure 管道上运行空手道 API 测试 [英] How to Run Karate API tests on Azure pipelines

查看:28
本文介绍了如何在 Azure 管道上运行空手道 API 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

空手道新手蔚蓝.刚刚使用空手道创建了几个 API 测试,简单简单.想要进一步添加 Azure 管道.

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

发现几个链接只指向从 Microsoft 添加 pom.xml 和 maven.还发现了 Jekins 集成,但没有用于 Azure.

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

未知/如何.

  1. 需要将哪些文件移动到管道中,例如 jar、war、xml 等

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

如何创建它们,我使用 intelliJ.

How to create them i use intelliJ.

有可用的分步教程吗?任何帮助表示赞赏.

Any step by step tutorials available? any help appreciated.

推荐答案

要在 azure devops 管道上运行空手道测试,您可以按照以下一般步骤构建/测试 java 项目.

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

1、首先使用 Maven 创建您的空手道测试项目.在 pom.xml 中添加相关的依赖和插件.请参阅此处的示例.

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

2、将本地源代码(例如.feature/.java/pom.xml 等)推送到github,或azure devop git 存储库.不需要推送.jar依赖,因为依赖可以通过pipeline中的Maven任务下载.

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、创建azure管道,关注这个例子 来创建一个 Yaml 格式的管道.如果您想创建经典的 UI 视图管道,请按照此处的示例进行操作.

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、添加Maven 任务在您的管道中运行空手道测试:请参阅以下 Yaml 示例.

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

如果您使用 Microsoft 云托管代理来运行您的管道,则需要确保通过 Karate 测试的 API 可以从云托管代理访问.(即 API 可以公开访问)

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)

如果 API 服务器在本地托管,则需要创建 自托管代理,并在自托管代理上运行 azure 管道.

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

这篇关于如何在 Azure 管道上运行空手道 API 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆