gpt4 book ai didi

java - JBehave 模糊步骤

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:02:53 26 4
gpt4 key购买 nike

假设我有:

@Given("first name is $firstName")
@Given("first name is $firstName and last name is $lastName")

以下步骤将被标记为不明确:

Given first name is John and last name is Smith

如果不使用引号将第一个参数括起来,我该如何修正这一步,使其只匹配第二个参数?使用引号分别包围两个参数也有同样的歧义问题。

每个参数的长度有限制吗?是否有某些字符不能传入?

最佳答案

您可以通过使用步骤优先级来解决此问题,如此处所述:http://jbehave.org/reference/stable/prioritising-steps.html

您的问题可以通过为具有两个参数的变体设置更高的优先级来解决:

@Given("first name is $firstName")
@Given(value = "first name is $firstName and last name is $lastName", priority = 1)

我试过你的例子,通过这种组合,两个步骤被分开了。

(编辑:我最初的解决方案对参数有引号,但没有它也能工作)

关于java - JBehave 模糊步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13713679/

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