如何避免在 Gherkin 中将数字捕获为数字参数?

How to avoid digit being captured as numeric argument in Gherkin?

我是小黄瓜的新手。

我正在用 Gherkin 编写以下语句:

Given user have institution_1 in database

这里 institution_1 对我来说只是一个普通名词,我不希望它成为一个变量或索引为“1”。

Cucumber-JVM 自动生成的Java函数是:

@Given("^user have institution_(\d+) in database as follows:$")
public void user_have_institution__in_database(int arg1) throws Throwable {
}

我如何重写它以便 Cucumber-JVM 识别“1”没有特殊含义,return 对我来说是这样的:

@Given("^user have institution_1 in database as follows:$")
public void user_have_institution_1_in_database() throws Throwable {
}

谢谢!

编辑: 我的问题是:Cucumber-JVM 看到每个数字都是 Gherkins 作为数字参数,例如

"institution_1" 

转换为:

 "institution_(\d+)" 

和 java 函数将有一个

(int arg1) 

争论。

我想要的是让 Cucumber-JVM 不转换为:

@Given("^user have institution_(\d+) in database as follows:$")

但是像这样:

@Given("^user have institution_1 in database as follows:$") 

或正则表达式将捕获它但没有参数的其他形式。因为在常识中,XXXXX_1中的1不是数字参数,而是字符。

如果那不可能,我怎么能让它工作?

@Given("^user have institution_(\d+) in database as follows:$")
public void user_have_institution__in_database() throws Throwable {
}

手动编辑生成的 Gherkin 为:

@Given("^user have institution_1 in database as follows:$")
public void user_have_institution_in_database() throws Throwable {
}