按标识运行已发布的测试

描述

“按标识运行已发布的测试”端点可执行 API 挂钩作用域内的单个指定测试。

HTTP 请求

POST <API-Hook- URL > /tests/ {Test-ID} /run

样本方法调用

curl -X POST \
    -H X-API-Key:{API-Key} \
    -H X-API-Secret:{API-Secret} \
    -H Content-Type:application/json \
    -d '
        {
          "options": {
              "allAssertions": boolean,
              "JUnitFormat": boolean
          },
          "variables": {
              string: string,
          }
        }
      ' \
    <API-Hook-URL>/tests/{Test-ID}/run

头参数

API密钥 API密钥

MIME 类型:application/json


{
    options: {
        allAssertions: boolean,
        JUnitFormat: boolean
    },
    variables: {
        string: string,
    }
  }

主体参数

  • options(仅在提供子元素时才需要此参数)
    • 包含有关如何在响应中返回数据或如何格式化响应的选项的包装器对象。
    • 子元素:
      • allAssertions(可选)
        • 如果为 false,那么仅返回测试中失败断言的结果。 如果为 true,那么将返回测试中的所有断言。 缺省状态下,allAssertionsfalse
      • JUnitFormat(可选)
        • 如果为 false,那么将返回 application/json 格式的测试结果。 如果为 true,那么将使用 text/xml JUnit 格式的测试结果(请参阅 text/xml 响应)。 缺省情况下,JUnitFormatfalse
  • variables(可选)
    • “variables”部分用于将指定变量及其值的列表传递到正在运行的测试。 它仅供专为使用这些变量而编写的测试使用,并且这些变量中存储了值。 如果将变量名称声明为对象键,并将其新值声明为该键的值(字符串类型),那么将会覆盖测试中与该对象键共享名称的变量的当前值。

MIME 类型:application/json

application/json

[
    {
      testRunId: string,
      testId: string,
      testName: string,
      location: string,
      initiated: string,
      duration: integer,
      status: enum['passed' or 'failed'],
      reportUrl: string,
      results: {
        warningsCount: integer,
        failureCount: integer,
        httpFailures: array[object],
        criticalFailures: array[object],
        assertions: array[object]
      }
    }
  ]

响应描述

  • testRunID
    • 运行测试的标识。
  • testId
    • 已执行的测试的标识。
  • testName
    • 测试的名称。
  • location
    • 执行测试的代理的位置。
  • initiated
    • 启动测试的日期和时间。
  • duration
    • 测试运行的总持续时间(以秒为单位)。
  • status
    • 测试的总体结果。
  • reportUrl
    • 测试运行报告的 URL。
  • results
    • 包含测试运行结果的包装器对象。
    • 子元素:
      • warningsCount
        • 测试断言返回的 HTTP 警告的计数。
      • failureCount
        • 大于 400 的 HTTP 状态码响应的计数。
      • httpFailures
        • HTTP 状态响应代码大于或等于 400 的故障的描述。
      • criticalFailures
        • HTTP 状态响应代码大于或等于 500 的故障的描述。
      • assertions
        • 测试中执行的断言的描述。 缺省情况下,将仅列出失败的断言。

MIME 类型:text/xml


<?xml version="1.0" encoding="UTF-8"?>
  <testSuite name="" tests="" disabled="" errors="" failures="" timestamp="" time="">
    <testcase name="" classname="" time="">
      <failure message="" type="" />
    </testcase>
  </testSuite>

响应描述

  • <testSuite>
    • 子元素:<testCase>
    • 属性:
      • name
        • 测试套件名称。
      • tests
        • 已运行的发布测试数。
      • disabled
        • 已禁用的测试数。
      • errors
        • 错误数。
      • failures
        • 测试套件中失败的测试数。
      • timestamp
        • 测试运行的日期和时间。
      • time
        • 所有测试运行的总持续时间(以秒为单位)。
  • <testCase>
    • 子元素:<failure>
    • 属性:
      • name
        • 测试名称。
      • classname
        • 已执行的测试的标识。
      • time
        • 测试运行的总持续时间(以秒为单位)。
  • <failure>
    • 属性:
      • message
        • 包含预期响应和实际响应的故障消息。
      • type
        • 故障类型。