是否可以在条件语句中使用空手道“匹配”? [英] Is it possible to use karate 'match' inside conditional statement?

查看:67
本文介绍了是否可以在条件语句中使用空手道“匹配”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此处查找示例。

  def a =条件? 空手道比赛声明:空手道比赛声明 

是否可以这样做?

解决方案

不推荐将其用于测试,因为


karate.match()的结果将以 {pass:'#boolean',message:'#string'}


如果以上选项均不起作用-这意味着您正在做的事情确实复杂,因此编写Java互操作代码/ a 来处理此问题


Find the example here.

def a = condition ? " karate match statement " : "karate match statement"

Is it possible to do something like this??

解决方案

This is not recommended practice for tests because tests should be deterministic.

The right thing to do is:

That said, if you really insist on doing this in the same flow, Karate allows you to do a match via JS in 0.9.6.RC4 onwards.

See this thread for details: https://github.com/intuit/karate/issues/1202#issuecomment-653632397

The result of karate.match() will return a JSON in the form { pass: '#boolean', message: '#string' }

If none of the above options work - that means you are doing something really complicated, so write Java interop / code to handle this

这篇关于是否可以在条件语句中使用空手道“匹配”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆