从空手道 DSL 中的 .properties 文件中读取数据

Reading data from .properties file in Karate DSL

我们正在尝试与另一个使用 Webdriver 等的 java 项目共存。作为其中的一部分,我们想重新使用其他项目用于我们的配置等的相同 .properties 文件. 有人可以指导我们在空手道 DSL 中读取 .properties 文件吗?

空手道没有内置任何内容 - 但您的解决方案很明确,编写一个简单的 Java 实用程序来读取属性文件 - 或者因为它是如此简单,您应该能够做到这一点即使在 JS 中,在 karate-config.js 本身。

同时参考这个:https://github.com/intuit/karate#calling-java

我还没有测试下面的代码,但你明白了:

* def stream = read('classpath:myfile.properties')
* def props = new java.util.Properties()
* eval props.load(stream)