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("""^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,那么它可以正常工作,但我想对我的代码使用Scenaio Outline。

  1. 我正在使用我的功能文件中的标记来运行我的测试用例。当我用命令sbt-test@tag1运行我的测试用例时,测试用例执行得很好,但当所有测试用例都在cmd上完成运行时,我会得到以下错误:

    [error] Expected ';'
    [error] @tag1 
    

我试着把"在标记之后,但仍然得到相同的错误这个问题是什么?我该如何解决?

  1. 我的应用程序中有4-5个功能文件。这意味着4-5个标签。到目前为止,我想运行的测试用例给出了特性文件的路径和";"胶水";在我的Runner Class中,它与step-denition配合使用。如何在Runner类中提供所有标记,以便我的应用程序在启动时逐一运行所有测试用例

<type>:周围缺少双引号

When A data of "<type>" is received

只是一些一般建议。

当cuking保持事情尽可能简单,关注清晰和简单,不要担心重复。

如果你写了两个简单的场景,你的任务会简单得多

Scenario: Personal data
Given Portal is running
When personal data is received
Then personal data should be persisted
Scenario: Professional data
...

其次,不要使用标签来运行您的功能,您还不需要标签。

如果你避免场景大纲、正则表达式、标记、转换等,你可以更有效地Cucumber。Cucumber的主要功能是使用自然语言清晰地表达自己。专注于此并保持简单。。。

最新更新