Karate 空手道比赛中的每一项

Karate 空手道比赛中的每一项,karate,Karate,我想断言,总价格大于等于净价格。你能告诉我怎样才能正确地做到这一点吗?这就是我所做的 Scenario: Testing * def response = """ { "prices": [ { "price_net":"10.50", "price_gross":"12.25" }, { "price_net":"10.50", "price_gross":"12.25" }, { "price_net":"10.50", "price_gross":"12.2

我想断言,总价格大于等于净价格。你能告诉我怎样才能正确地做到这一点吗?这就是我所做的

Scenario: Testing

* def response =

"""
{
  "prices": [
    { "price_net":"10.50", "price_gross":"12.25" },
    { "price_net":"10.50", "price_gross":"12.25" },
    { "price_net":"10.50", "price_gross":"12.25" },
    { "price_net":"10.50", "price_gross":"12.25" },
    { "price_net":"10.50", "price_gross":"12.25" },
    { "price_net":"10.50", "price_gross":"12.25" }
   ]
}

"""

* match each response.prices[*].price_gross == '#? _ >= 0 && _ >= response.prices[*].price_net'
我认为断言语句中的“*”是问题所在。因为当我运行这个

* match response.prices[0].price_gross == '#? _ >= 0 && _ >= response.prices[0].price_net'
它很好用。请建议。提前谢谢

示例代码:

Feature: Validation

  Scenario: Validation

    * def diff =
      """
      function (A, B) {

      var C = [];
      for(var i = 0; i < A.length; i++) {
      C.push(parseFloat(A[i]) - parseFloat(B[i]));
      }
      return C;
      }
      """

    * def response =
      """
      {
        "prices": [
          { "price_net":"10.50", "price_gross":"12.25" },
          { "price_net":"10.50", "price_gross":"12.25" },
          { "price_net":"10.50", "price_gross":"12.25" },
          { "price_net":"10.50", "price_gross":"12.25" },
          { "price_net":"10.50", "price_gross":"12.25" },
          { "price_net":"10.50", "price_gross":"12.25" }
        ]
      }
      """
    * json temp = response
    * def pgarr = get temp.prices[*].price_gross
    * def pnarr = get temp.prices[*].price_net
    * def sub = diff(pgarr,pnarr)
    * match each sub == '#? _ >= 0'
功能:验证
场景:验证
*def diff=
"""
功能(A、B){
var C=[];
对于(变量i=0;i=0'

这里有一个更简单的方法:
*def isValid=function(x){return x.price\u gross*1>x.price\u net*1}*匹配每个响应。prices=='#?isValid(41;)