Bdd黄瓜问题
Bdd Cucumber issues
我刚刚开始研究 BDD Cucumber。我正在使用 scala 编写测试用例。我正在尝试使用场景大纲并在步骤定义中传递参数。我的代码如下。
Scenario Outline: Data is parsed and persisted
Given Portal is running
When A data of <type> is received
Then The data of <type> with <Id> should be parsed and persisted
Examples:
| type | Id |
| Personal | 1 |
|Professional | 2 |
现在在我的 when 条件下,我试图按如下方式获取这些参数
When("""^A data of \"([^\"]*)\" is received$""") {
(type: String) =>
//My code
}
现在 运行我的代码每次都出现以下错误。
io.cucumber.junit.UndefinedStepException: The step "A data of Personal is received" is undefined. You can implement it using the snippet(s) below:
When("""A data of Personal is received""") { () =>
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.scala.PendingException()
}
尽管我在什么时候有了我的代码。另外,如果我不使用 Scenario Outline 那么它可以正常工作,但我想为我的代码使用 Scenario Outline。
我在我的功能文件中使用标签 运行 我的测试用例。当我使用命令 sbt test @tag1 运行 我的测试用例时,测试用例执行得很好但是当所有测试用例都完成时 运行 在 cmd 上我收到以下错误:
[error] Expected ';'
[error] @tag1
我试着把“;”标记后但仍然出现相同的错误
这是什么问题,我该如何解决?
- 我的应用程序中有 4-5 个功能文件。这意味着 4-5 个标签。到目前为止,我想要的测试用例 运行 我给出了特征文件的路径,并在我的 Runner Class 中用步骤定义“粘合”它。我如何在我的 Runner class 中提供所有标签,以便我的应用程序 运行 在启动时一一包含所有测试用例?
您缺少 <type>
:
两边的双引号
When A data of "<type>" is received
只是一些一般性建议。
cuking 时尽量简单,注重清晰和简单,不要担心重复。
如果您编写 2 个简单的场景,您的任务会简单得多
Scenario: Personal data
Given Portal is running
When personal data is received
Then personal data should be persisted
Scenario: Professional data
...
其次,不要使用标签来运行你的功能,你还不需要标签。
如果你避免场景大纲、正则表达式、标签、转换等,你可以更有效地使用 Cucumber。Cucumber 的主要功能是使用自然语言来清楚地表达自己。专注于此并保持简单......
我刚刚开始研究 BDD Cucumber。我正在使用 scala 编写测试用例。我正在尝试使用场景大纲并在步骤定义中传递参数。我的代码如下。
Scenario Outline: Data is parsed and persisted
Given Portal is running
When A data of <type> is received
Then The data of <type> with <Id> should be parsed and persisted
Examples:
| type | Id |
| Personal | 1 |
|Professional | 2 |
现在在我的 when 条件下,我试图按如下方式获取这些参数
When("""^A data of \"([^\"]*)\" is received$""") {
(type: String) =>
//My code
}
现在 运行我的代码每次都出现以下错误。
io.cucumber.junit.UndefinedStepException: The step "A data of Personal is received" is undefined. You can implement it using the snippet(s) below:
When("""A data of Personal is received""") { () =>
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.scala.PendingException()
}
尽管我在什么时候有了我的代码。另外,如果我不使用 Scenario Outline 那么它可以正常工作,但我想为我的代码使用 Scenario Outline。
我在我的功能文件中使用标签 运行 我的测试用例。当我使用命令 sbt test @tag1 运行 我的测试用例时,测试用例执行得很好但是当所有测试用例都完成时 运行 在 cmd 上我收到以下错误:
[error] Expected ';' [error] @tag1
我试着把“;”标记后但仍然出现相同的错误 这是什么问题,我该如何解决?
- 我的应用程序中有 4-5 个功能文件。这意味着 4-5 个标签。到目前为止,我想要的测试用例 运行 我给出了特征文件的路径,并在我的 Runner Class 中用步骤定义“粘合”它。我如何在我的 Runner class 中提供所有标签,以便我的应用程序 运行 在启动时一一包含所有测试用例?
您缺少 <type>
:
When A data of "<type>" is received
只是一些一般性建议。
cuking 时尽量简单,注重清晰和简单,不要担心重复。
如果您编写 2 个简单的场景,您的任务会简单得多
Scenario: Personal data
Given Portal is running
When personal data is received
Then personal data should be persisted
Scenario: Professional data
...
其次,不要使用标签来运行你的功能,你还不需要标签。
如果你避免场景大纲、正则表达式、标签、转换等,你可以更有效地使用 Cucumber。Cucumber 的主要功能是使用自然语言来清楚地表达自己。专注于此并保持简单......