【问题标题】:Cucumber rescue Exception (Ruby/HTTParty)黄瓜救援异常 (Ruby/HTTParty)
【发布时间】:2019-11-11 15:02:24
【问题描述】:

我只是在运行 Cucumber 测试时遇到异常,我试图找到我能做些什么,但没有运气。

当我在最后一步发帖时:

When('accept terms of use') do
  until @o == 200
  @o = CadastroApp.sign_term1.code
  sleep 1
  end
end

class CadastroApp
  include HTTParty
   def self.sign_term1
   post("#{$uat_uri}agree/multipleterms",
     body: {
       'ContractsId': $contract1,
       'deviceType': 'Smartphone',
       'Platform': 'ios',
       'Model': 'Iphone XS max',
     }.to_json,
     headers: {
       'Authorization': "Bearer #{$auth_token}",
       'Content-Type': 'application/json'
     })
   end
  end

我得到了错误:

52: def self.cucumber_run_with_backtrace_filtering(pseudo_method)
53:   begin
54:     yield
55:   rescue Exception => e
56:     instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
57:     replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
58:     raise e
59:   end
60: end

我不知道这是否是一个问题,但我使用了很多“直到 @variable == 200”来循环 api,直到我得到响应代码 200。

【问题讨论】:

  • 这不是错误。发布堆栈跟踪。
  • @anothermh 我该怎么做?我试图输入 wtf 命令,但只得到“错误:没有最近的异常”
  • 好的,我正确使用了 wtf 命令,但是得到了这个“错误:没有最近的异常”响应
  • 也许 api 正在产生这种救援?即使有 200 和 ok 的消息
  • “我只是在运行 Cucumber 测试时遇到异常”如果您没有看到异常,您怎么知道您遇到了异常?

标签: ruby cucumber httparty


【解决方案1】:

这是一个 MYSQL 问题。当我请求 API 时,MYSQL 不会关闭请求,所以当我检查 Kubernetes 时会出现很多超时。

Exception Caught by LogRequestResponseMiddleware:
1) ----- Exception Type
MySql.Data.MySqlClient.MySqlException
1) ----- Exception Source
MySql.Data
1) ----- Exception TargetSite
MySql.Data.MySqlClient.Driver GetConnection()
1) ----- Exception Message
error connecting: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.
Message = error connecting: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reac
hed.

所以我重新发布了 API,自动化工作正常。

【讨论】:

    【解决方案2】:

    这不是错误。这是当我在步骤中失败时 Ruby 发送的响应。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-24
      • 1970-01-01
      • 2012-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-16
      相关资源
      最近更新 更多