gpt4 book ai didi

karate - 使用 Karate API forEach 方法时出现 "no step-definition method match"错误

转载 作者:行者123 更新时间:2023-12-02 19:53:04 25 4
gpt4 key购买 nike

我尝试在我的一个功能文件中使用 forEach 方法,但我不断收到此错误:“没有找到匹配的步骤定义方法:forEach...”

我什至尝试使用 Karate documentation 中的示例但还是不行。

这是我的运行者:

import com.intuit.karate.junit4.Karate;
import com.intuit.karate.KarateOptions;
import org.junit.runner.RunWith;

@RunWith(Karate.class)
@KarateOptions(features = "classpath:com/kenshoo/apitests/testForEach.feature")
public class ApiTestsRunner {

}

这是我的功能文件:

Feature: Test forEach

Scenario: karate forEach operation on lists
* def res = []
* def fun = function(x){ karate.appendTo(res, x * x) }
* def list = [1, 2, 3]
* forEach(list, fun)
* match res == [1, 4, 9]

这是我遇到的错误:

testForEach.feature:7 - no step-definition method match found for: forEach(list, fun)
com.intuit.karate.exception.KarateException: testForEach.feature:7 - no step-definition method match found for: forEach(list, fun)
at ✽.* forEach(list, fun) (testForEach.feature:7)

Karate API 版本 - 0.9.3

最佳答案

我在 0.9.3 版本中重现了您的错误。更新到版本 0.9.4 将解决该问题。

在 0.9.4 中,“eval”关键字变为可选。这就是您收到“无步骤定义...”错误的原因。

请参阅此处的发行说明: https://github.com/intuit/karate/releases


令人遗憾的是,作者花更多时间向人们竖起中指并说“RTFM”,而不是真正提供帮助。我想有些人忘记了学习一门新语言的挑战,特别是对于新手开发人员来说。 @EB123...您只是“忽略”了托马斯先生提出的答案是出于傲慢而不是谦虚而写的这一事实。

关于karate - 使用 Karate API forEach 方法时出现 "no step-definition method match"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57747276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com