空手道中的自定义类型转换

Custom type conversion in Karate

由于空手道支持 type conversion,我想知道是否可以编写自定义类型转换,以便我可以在我的 .feature 文件中编写与此类似的内容

customType customTypeResponse = response

应该与

具有相同的语义
yaml yamlResponse = response

但是对于 customType 而不是 yaml。

我想我找到了 code enabling the custom type conversion。但是我不确定可扩展性。

因此最短的方法可能是使用 Java interop 启用这样的东西

def customTypeResponse = CustomType.convert(response)

请让我知道类型转换的任何可能性。

是的,我强烈建议只使用 Java 互操作而不是 complicating it further for now。也许将来我们会有更好的方法来贡献自定义语法(提示:寻找 Plugin 接口以及 karate-robot 如何使用它)。