如何在 Azure 管道上 运行 空手道 API 测试

How to Run Karate API tests on Azure pipelines

空手道和 Azure 的新手。刚刚使用空手道创建了几个 API 测试,简单易行。想要进一步添加它的 Azure 管道。

找到几个指向添加 pom.xml 和来自 Microsoft 的 maven 的链接。还发现了 Jekins 集成,但 none 用于 Azure。

未知/如何。

  1. 什么文件需要移动到管道,eg,jar,war,xml等

  2. 如何创建它们我使用 intelliJ。

  3. 有分步教程吗?任何帮助表示赞赏。

要在 azure devops 管道上进行 运行 空手道测试,您可以按照以下针对 building/testing java 项目的一般步骤进行操作。

1,首先使用 Maven 创建空手道测试项目。在pom.xml中添加相关的依赖和插件。参见示例 here.

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

3、创建蔚蓝管道,关注this example to create a Yaml format pipeline. If you want to create a classic UI view pipeline, follow the example here.

4,在您的管道中添加 Maven task 到 运行 空手道测试:参见下面 Yaml 中的示例。

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

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

如果 API 服务器在本地托管,您需要在 self-hosted 代理上创建 self-hosted agent 和 运行 Azure 管道。