#ignore和#present是同一件事吗? [英] Are #ignore and #present the same thing?

查看:61
本文介绍了#ignore和#present是同一件事吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在什么情况下我想使用#ignore#present或相反?还是相同?

What's a case where I'd want to use #ignore vs. #present or vice-versa? Or are they identical?

我第一次阅读文档时,我认为以下内容将会通过,但事实并非如此. 编辑以添加:在空手道0.9.0中失败,但在0.8.0中通过.

My first read of the docs I thought the following would pass, but it does not. Edit to add: This fails in Karate 0.9.0 but passes in 0.8.0.

* def foo = {a: 1}
* match foo == {a: 1, b: "#ignore"}

这些通过:

* def foo = {a: 1}
* match foo == {a: 1, b: "##ignore"}
* match foo == {a: 1, b: "##present"}

推荐答案

不,#ignore#present不应具有相同的行为.

No, #ignore and #present are not intended to have the same behavior.

空手道0.9.0中有一个错误,导致它们的行为相同,但这是已修复.

There was a bug in Karate 0.9.0 that caused them to behave the same, but that is fixed.

#ignore应该与是否存在密钥相匹配.

#ignore should match whether or not the key is present.

# This case would NOT match with '#present'
# This case fails in Karate 0.9.0 due to a bug
* def foo = {}
* match foo == { a: '#ignore' }

# These cases would also match with '#present'
* def foo = {a: null}
* match foo == { a: '#ignore' }
* def foo = {a: "bar"}
* match foo == { a: '#ignore' }

这篇关于#ignore和#present是同一件事吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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