无法使用类路径或相对路径读取 json 负载数据

Unable to use classpath or relative path to read json payload data

我编写了一个空手道场景,其中我的登录是从一个单独的 .feature 文件执行的。我有以下目录结构:

src/test/java/feature/common/common.feature

当我想从不同文件夹(如下)中的另一个功能文件调用上述公共功能文件时,它不起作用:

src/test/java/feature/tests/test.feature

我试过以下方法:

1.

  • callonce read('feature/common/common.feature') and it does not work.
  1. 如果我要使用类路径,我将如何编写此调用?

使用 classpath: 如果您遵循标准 karate workspace structure

,您将能够访问 src/test/java 中的内容

为了通话/阅读,

* call read('classpath:feature/common/common. feature')

简单的src/test/java可以换成classpath:

Refer reading files 更多来自空手道文档