空手道有没有办法在变量中获取断言状态,如通过或失败,以便在 java 中进一步处理?

Is there way in karate to get the assertion status like pass or fail in variable for further processing in java?

在功能文件中,我将断言写为

match response contains {token_type: '#string' }

有没有办法获取上述断言值的输出状态,如真或假, 以便我可以将其扩展到 java 以进行进一步处理?

空手道的全部意义在于避免Java,我不建议做任何其他事情。

但既然你坚持,如果你想得到上面的等价物,就这样做吧。是的,你必须使用 "normal" JS 基础。

* def response = { token_type: 'foo' }
* def isString = typeof(response.token_type) === "string"
* match isString == true