【问题标题】:CircleCI postman API automate testing not workingCircleCI 邮递员 API 自动化测试不起作用
【发布时间】:2021-05-30 10:37:04
【问题描述】:

我在 circleci 上遇到邮递员的挑战。我的config.yml 看起来像这样。

version: 2.1
orbs:
  newman: postman/newman@0.0.2
jobs:
  build:
    newman-collection-run-env-timeout:
    executor: newman/postman-newman-docker
    steps:
      - checkout
      - newman/newman-run:
          collection: ./collection/new_test.postman_collection.json
          environment: ./env/New-lamp-staging.postman_environment.json

当我部署到 circleci 时,我得到了这个错误

❏ auth
↳ Register: 201 Created
  POST https://stagingauth.herokuapp.com/auth/accounts/register/ [415 Unsupported Media Type, 377B, 109ms]
  1. Status code is 201

↳ Register: 400 Bad Request
  POST https://stagingauth.herokuapp.com/auth/accounts/register/ [415 Unsupported Media Type, 377B, 19ms]
  2. Status code is 400

请问我做错了什么?

【问题讨论】:

  • 报错说服务器不接受请求体,在postman中调试看看
  • @PDHide 它在邮递员上运行良好。 Circleci 没有将请求正文识别为 json 对象。
  • 这是最新的版本,2019年创建的,如果你有更新的版本,请分享。
  • 尝试使用 newman npm 模块运行该 json 文件,可能是您没有正确导出集合和环境
  • 我做到了,当我执行 newman run @PDHide 时它起作用了。请检查此要点以获取结果gist.github.com/bhadmus/d55576460920e210594c02e28859bcf8

标签: api continuous-integration postman circleci newman


【解决方案1】:

你有两个不同的采集结果,看你在git中上传的结果文件,url是

https://stagingauth.herokuapp.com/auth/token/jwt

但在 CI 圈中的 url 是

https://stagingauth.herokuapp.com/auth/token

所以你试图对错误的资源执行发布操作,这就是为什么得到 415

请确保您使用正确的集合和环境文件和 url,并且变量值正确

【讨论】:

  • Login: 200 status POST https://stagingauth.herokuapp.com/auth/token/jwt [415 Unsupported Media Type, 377B, 70ms] 1. Test To verify that the status code is 200 仍然返回与 url 相同的错误
  • 如果您使用相同的集合和环境文件,为什么 azure 和其他运行会指向不同的 url。文件有差异,请重新验证
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-05-14
  • 1970-01-01
  • 2022-06-13
  • 2017-05-19
  • 2021-05-12
  • 2021-04-16
相关资源
最近更新 更多